17 #ifndef INCLUDE_STRTK_HPP
18 #define INCLUDE_STRTK_HPP
44 #ifndef strtk_no_tr1_or_boost
45 #define strtk_enable_lexical_cast
46 #define strtk_enable_random
47 #define strtk_enable_regex
50 #ifdef strtk_enable_lexical_cast
51 #include <boost/lexical_cast.hpp>
54 #ifdef strtk_enable_random
57 #include <boost/random.hpp>
60 #ifdef strtk_enable_regex
63 #include <boost/regex.hpp>
70 static const std::size_t one_kilobyte = 1024;
71 static const std::size_t one_megabyte = 1024 * one_kilobyte;
72 static const std::size_t one_gigabyte = 1024 * one_megabyte;
73 static const std::size_t magic_seed = 0xA5A5A5A5;
75 template <
typename Tokenizer,
typename Function>
80 std::size_t token_count = 0;
81 tokenizer.assign(buffer);
82 typename Tokenizer::iterator itr = tokenizer.begin();
83 typename Tokenizer::const_iterator end = tokenizer.end();
93 template <
typename Function>
96 const std::size_t& buffer_size = one_kilobyte)
99 buffer.reserve(buffer_size);
100 std::size_t line_count = 0;
101 while (std::getline(stream,buffer))
109 template <
typename Function>
111 const std::size_t& n,
113 const std::size_t& buffer_size = one_kilobyte)
116 buffer.reserve(buffer_size);
117 std::size_t line_count = 0;
118 while (std::getline(stream,buffer))
121 if (n == ++line_count)
127 template <
typename Function>
130 const std::size_t& buffer_size = one_kilobyte)
132 std::ifstream stream(file_name.c_str());
139 template <
typename Function>
141 const std::size_t& n,
143 const std::size_t& buffer_size = one_kilobyte)
145 std::ifstream stream(file_name.c_str());
152 template <
typename Function>
155 const std::size_t& buffer_size = one_kilobyte)
158 buffer.reserve(buffer_size);
159 std::size_t line_count = 0;
160 while (std::getline(stream,buffer))
162 if (!
function(buffer))
171 template <
typename Function>
173 const std::size_t& n,
175 const std::size_t& buffer_size = one_kilobyte)
178 buffer.reserve(buffer_size);
179 std::size_t line_count = 0;
180 while (std::getline(stream,buffer))
182 if (!
function(buffer))
186 if (n == ++line_count)
192 template <
typename Function>
195 const std::size_t& buffer_size = one_kilobyte)
197 std::ifstream stream(file_name.c_str());
204 template <
typename Function>
206 const std::size_t& n,
208 const std::size_t& buffer_size = one_kilobyte)
210 std::ifstream stream(file_name.c_str());
217 template <
typename T>
220 const std::size_t& buffer_size = one_kilobyte)
223 buffer.reserve(buffer_size);
224 if (!std::getline(stream,buffer))
256 template <
typename T>
262 template <
typename T>
268 template <
bool,
typename T =
void>
271 template <
typename T>
274 template <
typename T>
280 template <
typename T>
287 template <
typename T>
inline std::size_t
type_length(
const T&);
292 template <
typename T>
299 template <
typename T>
303 #define register_stl_container1(C) \
304 template <typename T1, typename T2>struct is_stl_container<C<T1,T2> >{ typedef yes_t result_t; };
306 #define register_stl_container2(C) \
307 template <typename T1, typename T2, typename T3>struct is_stl_container<C<T1,T2,T3> >{ typedef yes_t result_t; };
318 #undef register_stl_container1
319 #undef register_stl_container2
323 template <
typename Iterator,
typename T>
328 Iterator itr = begin;
332 template <
typename Iterator,
typename T>
338 template <
typename T,
typename Iterator>
344 Iterator itr = begin;
348 throw std::invalid_argument(
"string_to_type_converter() - Failed to convert: " +
352 template <
typename T,
typename Iterator>
355 return string_to_type_converter<T>(range.first,range.second);
358 template <
typename T>
361 return string_to_type_converter<const char*,T>(s.data(),s.data() + s.size(),t);
364 template <
typename T>
367 return string_to_type_converter<T>(s.data(),s.data() + s.size());
370 template <
typename T>
377 template <
typename T>
381 if (type_to_string<T>(t,s))
384 throw std::invalid_argument(
"type_to_string() - Failed to convert type to string");
387 #define strtk_begin_register_string_to_type \
388 namespace strtk { namespace details {
390 #define strtk_end_register_string_to_type \
393 #define strtk_string_to_type_begin(Type) \
394 namespace strtk { namespace details { template <typename Iterator> \
395 inline bool string_to_type_converter_impl(const Iterator& begin, const Iterator& end, \
396 Type& t, details::not_supported_type_tag&) {
398 #define strtk_string_to_type_end()\
401 template <
typename T,
403 template <
typename,
typename>
class Sequence>
405 Sequence<T,Allocator>& sequence,
406 const std::size_t& buffer_size = one_kilobyte)
408 if (!stream)
return 0;
410 buffer.reserve(buffer_size);
411 std::size_t line_count = 0;
412 while (std::getline(stream,buffer))
415 sequence.push_back(string_to_type_converter<T>(buffer));
420 template <
typename T,
424 std::set<T,Comparator,Allocator>& set,
425 const std::size_t& buffer_size = one_kilobyte)
427 if (!stream)
return 0;
429 buffer.reserve(buffer_size);
430 std::size_t line_count = 0;
431 while (std::getline(stream,buffer))
434 set.insert(string_to_type_converter<T>(buffer));
439 template <
typename T,
443 std::multiset<T,Comparator,Allocator>& multiset,
444 const std::size_t& buffer_size = one_kilobyte)
446 if (!stream)
return 0;
448 buffer.reserve(buffer_size);
449 std::size_t line_count = 0;
450 while (std::getline(stream,buffer))
453 multiset.insert(string_to_type_converter<T>(buffer));
458 template <
typename T,
typename Container>
460 std::queue<T,Container>& queue,
461 const std::size_t& buffer_size = one_kilobyte)
463 if (!stream)
return 0;
465 buffer.reserve(buffer_size);
466 std::size_t line_count = 0;
467 while (std::getline(stream,buffer))
470 queue.push(string_to_type_converter<T>(buffer));
475 template <
typename T,
typename Container>
477 std::stack<T,Container>& stack,
478 const std::size_t& buffer_size = one_kilobyte)
480 if (!stream)
return 0;
482 buffer.reserve(buffer_size);
483 std::size_t line_count = 0;
484 while (std::getline(stream,buffer))
487 stack.push(string_to_type_converter<T>(buffer));
492 template <
typename T,
496 std::priority_queue<T,Container,Comparator>& priority_queue,
497 const std::size_t& buffer_size = one_kilobyte)
499 if (!stream)
return 0;
501 buffer.reserve(buffer_size);
502 std::size_t line_count = 0;
503 while (std::getline(stream,buffer))
506 priority_queue.push(string_to_type_converter<T>(buffer));
511 template <
typename T,
513 template <
typename,
typename>
class Sequence>
515 Sequence<T,Allocator>& sequence,
516 const std::size_t& buffer_size = one_kilobyte)
518 std::ifstream stream(file_name.c_str());
525 template <
typename T,
529 std::set<T,Comparator,Allocator>& set,
530 const std::size_t& buffer_size = one_kilobyte)
532 std::ifstream stream(file_name.c_str());
539 template <
typename T,
543 std::multiset<T,Comparator,Allocator>& multiset,
544 const std::size_t& buffer_size = one_kilobyte)
546 std::ifstream stream(file_name.c_str());
553 template <
typename T,
typename Container>
555 std::queue<T,Container>& queue,
556 const std::size_t& buffer_size = one_kilobyte)
558 std::ifstream stream(file_name.c_str());
565 template <
typename T,
typename Container>
567 std::stack<T,Container>& stack,
568 const std::size_t& buffer_size = one_kilobyte)
570 std::ifstream stream(file_name.c_str());
577 template <
typename T,
581 std::priority_queue<T,Container,Comparator>& priority_queue,
582 const std::size_t& buffer_size = one_kilobyte)
584 std::ifstream stream(file_name.c_str());
591 template <
typename T,
593 template <
typename,
typename>
class Sequence>
595 const Sequence<T,Allocator>& sequence,
598 if (!stream)
return 0;
600 std::size_t count = 0;
601 typename Sequence<T,Allocator>::const_iterator itr = sequence.begin();
602 typename Sequence<T,Allocator>::const_iterator end = sequence.end();
604 if (!delimiter.empty())
608 stream << (*itr) << delimiter;
625 template <
typename T,
629 const std::set<T,Comparator,Allocator>& set,
632 if (!stream)
return 0;
634 std::size_t count = 0;
635 typename std::set<T,Comparator,Allocator>::const_iterator itr = set.begin();
636 typename std::set<T,Comparator,Allocator>::const_iterator end = set.end();
638 if (!delimiter.empty())
642 stream << (*itr) << delimiter;
659 template <
typename T,
663 const std::multiset<T,Comparator,Allocator>& multiset,
666 if (!stream)
return 0;
668 std::size_t count = 0;
669 typename std::multiset<T,Comparator,Allocator>::const_iterator itr = multiset.begin();
670 typename std::multiset<T,Comparator,Allocator>::const_iterator end = multiset.end();
672 if (!delimiter.empty())
676 stream << (*itr) << delimiter;
693 template <
typename T,
695 template <
typename,
typename>
class Sequence>
697 const Sequence<T,Allocator>& sequence,
700 std::ofstream stream(file_name.c_str());
707 template <
typename T,
711 const std::set<T,Comparator,Allocator>& set,
714 std::ofstream stream(file_name.c_str());
721 template <
typename T,
725 const std::multiset<T,Comparator,Allocator>& multiset,
728 std::ofstream stream(file_name.c_str());
735 template <
typename InputIterator,
typename OutputIterator>
747 template <
typename Predicate,
748 typename InputIterator,
751 const InputIterator begin,
const InputIterator end,
754 InputIterator itr = begin;
765 template <
typename Predicate,
766 typename InputIterator,
769 const InputIterator begin,
const InputIterator end,
772 InputIterator itr = begin;
775 if (!predicate(*itr))
782 template <
typename Predicate,
783 typename InputIterator,
786 const InputIterator begin,
const InputIterator end,
789 InputIterator itr = begin;
799 template <
typename InputIterator,
typename OutputIterator>
803 typedef typename std::iterator_traits<InputIterator>::value_type
T;
804 std::vector<T> buffer(begin,end);
806 std::unique_copy(buffer.begin(),buffer.end(),out);
809 template <
typename Predicate,
typename InputIterator>
811 const InputIterator begin,
812 const InputIterator end)
814 InputIterator itr = begin;
817 if (!predicate(*itr))
828 template <
typename T>
849 end_(begin_ + length)
862 inline std::size_t
size()
const
869 return stringify(begin_,end_);
874 return *(begin_ + index);
879 return *(begin_ + index);
884 template <
typename Type>
903 template <
typename T>
909 template <
typename T, std::
size_t N>
917 return adapter<const char>(s.data(),s.size());
920 template <
typename T,
922 template <
typename,
typename>
class Sequence>
940 template <
typename T>
953 return delimiter_ == d;
962 template <
typename T>
970 : length_(std::
distance(d_begin,d_end)),
971 delimiter_((length_ <= sbo_buffer_size) ? sbo_buffer : new
T[length_]),
972 delimiter_end_(delimiter_ + length_)
974 std::copy(d_begin,d_end, delimiter_);
979 delimiter_((length_ <= sbo_buffer_size) ? sbo_buffer : new
T[length_]),
980 delimiter_end_(delimiter_ + length_)
982 std::copy(d,d + length, delimiter_);
985 template <
typename Iterator>
987 : length_(std::
distance(begin,end)),
988 delimiter_((length_ <= sbo_buffer_size) ? sbo_buffer : new
T[length_]),
989 delimiter_end_(delimiter_ + length_)
992 std::copy(begin,end, delimiter_);
995 template <
typename Type>
997 : length_(std::
distance(r.begin(),r.end())),
998 delimiter_((length_ <= sbo_buffer_size) ? sbo_buffer : new
T[length_]),
999 delimiter_end_(delimiter_ + length_)
1002 std::copy(r.
begin(),r.
end(), delimiter_);
1007 if (length_ > sbo_buffer_size)
1009 delete[] delimiter_;
1015 return (
std::find(delimiter_,delimiter_end_,d) != delimiter_end_);
1023 std::size_t length_;
1026 enum { sbo_buffer_size = 32 };
1027 T sbo_buffer[sbo_buffer_size];
1034 template <
typename Iterator>
1037 setup_delimiter_table(begin,end);
1042 setup_delimiter_table(s.data(),s.data() + s.size());
1047 return (delimiter_table_[c]);
1052 return operator()(static_cast<unsigned char>(c));
1057 static const std::size_t table_size = 256;
1059 template <
typename Iterator>
1060 inline void setup_delimiter_table(
const Iterator begin,
const Iterator end)
1062 std::fill_n(delimiter_table_,table_size,
false);
1063 for (Iterator itr = begin; itr != end; ++itr)
1065 delimiter_table_[
static_cast<unsigned char>(*itr)] =
true;
1069 bool delimiter_table_[table_size];
1074 template <
typename Allocator,
1075 template <
typename,
typename>
class Sequence>
1080 :
itr_(sequence.begin()),
1081 end_(sequence.end()),
1086 template <
typename T>
1103 typename sequence_t::const_iterator
itr_;
1104 typename sequence_t::const_iterator
end_;
1110 template <
typename Allocator,
1111 template <
typename,
typename>
class Sequence>
1117 template <
typename Iterator,
typename Predicate>
1122 Iterator itr1 = begin;
1123 Iterator itr2 = begin;
1124 std::size_t removal_count = 0;
1127 if (predicate(*itr1))
1142 return removal_count;
1145 template <
typename T,
typename Predicate>
1151 template <
typename Predicate,
1154 template <
typename,
typename>
class Sequence>
1155 inline std::size_t
remove_inplace(Predicate predicate, Sequence<T,Allocator>& sequence)
1157 const std::size_t removal_count =
remove_inplace(predicate,sequence.begin(),sequence.end());
1158 sequence.resize(sequence.size() - removal_count);
1159 return removal_count;
1165 const_cast<char*>(s.data()),
1166 const_cast<char*>(s.data() + s.size()));
1167 if (removal_count > 0)
1169 s.resize(s.size() - removal_count);
1173 template <
typename Predicate>
1177 const_cast<char*>(s.data()),
1178 const_cast<char*>(s.data() + s.size()));
1179 if (removal_count > 0)
1181 s.resize(s.size() - removal_count);
1185 template <
typename Iterator,
typename Predicate>
1191 Iterator itr1 = begin;
1192 Iterator itr2 = begin;
1193 typename std::iterator_traits<Iterator>::value_type prev = *begin;
1194 std::size_t removal_count = 0;
1199 while ((end != itr1) && (!predicate(*itr1) || !predicate(prev)))
1210 while ((end != itr1) && predicate(*itr1))
1217 return removal_count;
1220 template <
typename T,
typename Predicate>
1228 if (s.empty())
return;
1230 const_cast<char*>(s.data()),
1231 const_cast<char*>(s.data() + s.size()));
1232 if (removal_count > 0)
1234 s.resize(s.size() - removal_count);
1240 if (s.empty())
return;
1242 const_cast<char*>(s.data()),
1243 const_cast<char*>(s.data() + s.size()));
1244 if (removal_count > 0)
1246 s.resize(s.size() - removal_count);
1252 #if (defined(__MINGW32_VERSION)) ||\
1253 (defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)) ||\
1254 (defined(_WIN32) && (_MSC_VER < 1400))
1255 inline std::size_t
strnlength(
const char* s,
const std::size_t& n)
1257 const char *end =
reinterpret_cast<const char*
>(memchr(s,
'\0', n));
1258 return end ? (size_t) (end - s) : n;
1261 inline std::size_t
strnlength(
const char* s,
const std::size_t& n)
1263 return strnlen(s,n);
1270 if (s.empty())
return;
1274 const_cast<char*>(s.data()),
1275 const_cast<char*>(s.data() + s.size()));
1276 if (removal_count > 0)
1278 s.resize(s.size() - removal_count);
1282 template <
typename Predicate>
1285 if (s.empty())
return;
1287 const_cast<char*>(s.data()),
1288 const_cast<char*>(s.data() + s.size()));
1289 if (removal_count > 0)
1291 s.resize(s.size() - removal_count);
1295 template <
typename Iterator>
1300 Iterator itr1 = begin; ++itr1;
1301 Iterator itr2 = begin; ++itr2;
1302 typename std::iterator_traits<Iterator>::value_type prev = *begin;
1303 std::size_t removal_count = 0;
1307 while ((end != itr1) && (prev != (*itr1)))
1318 while ((end != itr1) && (prev == (*itr1)))
1325 return removal_count;
1328 template <
typename T>
1334 template <
typename T,
1336 template <
typename,
typename>
class Sequence>
1340 sequence.resize(sequence.size() - removal_count);
1346 const_cast<char*>(s.data() + s.size()));
1348 if (removal_count > 0)
1350 s.resize(s.size() - removal_count);
1356 std::string::value_type table[0xFF];
1357 std::fill_n(table,0xFF,static_cast<char>(0));
1359 result.reserve(str.size());
1360 for (std::size_t i = 0; i < str.size(); ++i)
1362 const char c = str[i];
1363 if (0 == table[static_cast<std::size_t>(c)])
1365 table[
static_cast<std::size_t
>(c)] = 0x01;
1377 template <
typename Iterator,
typename Predicate>
1385 Iterator itr = begin + (length - 1);
1386 std::size_t removal_count = 0;
1388 while ((begin != itr) && predicate(*itr))
1394 return removal_count;
1397 template <
typename T,
typename Predicate>
1405 if (s.empty())
return;
1407 const_cast<char*>(s.data()),
1408 const_cast<char*>(s.data() + s.size()));
1409 if (removal_count > 0)
1411 s.resize(s.size() - removal_count);
1417 if (s.empty())
return;
1419 const_cast<char*>(s.data()),
1420 const_cast<char*>(s.data() + s.size()));
1421 if (removal_count > 0)
1423 s.resize(s.size() - removal_count);
1432 const_cast<char*>(s.data()),
1433 const_cast<char*>(s.data() + s.size()));
1434 if (removal_count > 0)
1436 s.resize(s.size() - removal_count);
1440 template <
typename Predicate>
1443 if (s.empty())
return;
1445 const_cast<char*>(s.data()),
1446 const_cast<char*>(s.data() + s.size()));
1447 if (removal_count > 0)
1449 s.resize(s.size() - removal_count);
1453 template <
typename Iterator,
typename Predicate>
1461 Iterator itr = begin;
1462 std::size_t removal_count = 0;
1464 while ((end != itr) && predicate(*itr))
1470 std::copy(itr,end,begin);
1471 return removal_count;
1474 template <
typename T,
typename Predicate>
1482 if (s.empty())
return;
1484 const_cast<char*>(s.data()),
1485 const_cast<char*>(s.data() + s.size()));
1486 if (removal_count > 0)
1488 s.resize(s.size() - removal_count);
1494 if (s.empty())
return;
1496 const_cast<char*>(s.data()),
1497 const_cast<char*>(s.data() + s.size()));
1498 if (removal_count > 0)
1500 s.resize(s.size() - removal_count);
1506 if (s.empty())
return;
1510 const_cast<char*>(s.data()),
1511 const_cast<char*>(s.data() + s.size()));
1512 if (removal_count > 0)
1514 s.resize(s.size() - removal_count);
1524 template <
typename Predicate>
1527 if (s.empty())
return;
1529 const_cast<char*>(s.data()),
1530 const_cast<char*>(s.data() + s.size()));
1531 if (removal_count > 0)
1533 s.resize(s.size() - removal_count);
1537 template <
typename Allocator,
1538 template <
typename,
typename>
class Sequence>
1541 struct is_empty {
static inline bool check(
const std::string& s) {
return s.empty(); } };
1542 seq.erase(std::remove_if(seq.begin(),seq.end(),is_empty::check),seq.end());
1545 template <
typename Allocator>
1548 struct is_empty {
static inline bool check(
const std::string& s) {
return s.empty(); } };
1549 l.remove_if(is_empty::check);
1552 template <
typename Comparator,
typename Allocator>
1555 struct is_empty {
static inline bool check(
const std::string& s) {
return s.empty(); } };
1556 typename std::set<std::string,Comparator,Allocator>::iterator itr = set.begin();
1557 while (set.end() != itr)
1566 template <
typename Comparator,
typename Allocator>
1569 struct is_empty {
static inline bool check(
const std::string& s) {
return s.empty(); } };
1570 typename std::multiset<std::string,Comparator,Allocator>::iterator itr = set.begin();
1571 while (set.end() != itr)
1580 template <
typename Iterator>
1581 inline void replace(
const typename std::iterator_traits<Iterator>::value_type& c1,
1582 const typename std::iterator_traits<Iterator>::value_type& c2,
1583 const Iterator begin,
1586 for (Iterator itr = begin; end != itr; ++itr)
1595 inline void replace(
const std::string::value_type& c0,
1596 const std::string::value_type& c1,
1599 replace(c0,c1,const_cast<char*>(s.data()),const_cast<char*>(s.data() + s.size()));
1602 template <
typename T>
1613 if (p.empty() || (p == r))
1619 const std::size_t p_size = p.size();
1620 const std::size_t r_size = r.size();
1621 int inc =
static_cast<int>(r_size) - static_cast<int>(p_size);
1622 std::size_t pos = 0;
1623 std::vector<std::size_t> delta_list;
1624 delta_list.reserve(std::min<std::size_t>(32,(s.size() / p_size) + 1));
1626 while (std::string::npos != (pos = s.find(p,pos)))
1628 delta_list.push_back(pos);
1632 if (delta_list.empty())
1638 n.resize(delta_list.size() * inc + s.size(), 0x00);
1639 char* n_itr =
const_cast<char*
>(n.data());
1640 const char* s_end = s.data() + s.size();
1641 const char* s_itr = s.data();
1642 const char* r_begin = r.data();
1643 const char* r_end = r.data() + r_size;
1644 const std::size_t delta_list_size = delta_list.size();
1646 std::size_t delta = delta_list[0];
1650 std::copy(s_itr, s_itr + delta, n_itr);
1651 s_itr += p_size + delta;
1653 std::copy(r_begin, r_end, n_itr);
1655 if (++i >= delta_list_size)
1657 delta = delta_list[i] - (delta_list[i - 1] + p_size);
1662 std::copy(s_itr, s_end, n_itr);
1666 template <
typename InputIterator,
typename OutputIterator>
1667 inline std::size_t
replace_pattern(
const InputIterator s_begin,
const InputIterator s_end,
1668 const InputIterator p_begin,
const InputIterator p_end,
1669 const InputIterator r_begin,
const InputIterator r_end,
1672 typedef typename std::iterator_traits<InputIterator>::value_type
T;
1674 InputIterator s_itr = s_begin;
1675 InputIterator r_itr = r_begin;
1676 InputIterator p_itr = p_begin;
1681 if ((0 == p_size) || ((p_size == r_size) && std::equal(p_begin,p_end,r_begin)))
1683 std::copy(s_begin,s_end,out);
1687 std::size_t pos = 0;
1688 std::size_t prev_pos = 0;
1689 std::size_t count = 0;
1691 int inc = r_size - p_size;
1693 InputIterator temp_s_itr = s_itr;
1695 while (s_end != s_itr)
1706 while ((p_end != p_itr) && (s_end != temp_s_itr))
1708 if (*(temp_s_itr++) != *(p_itr++))
1715 if (found && (p_itr == p_end))
1737 InputIterator pattern_start = temp_s_itr;
1739 while ((p_end != p_itr) && (s_end != temp_s_itr))
1741 if (*(temp_s_itr++) != *(p_itr++))
1744 temp_s_itr = pattern_start;
1750 if (!found || (p_itr != p_end))
continue;
1753 int diff = pos - prev_pos;
1755 std::copy(s_itr,s_itr + diff, out);
1757 std::copy(r_itr,r_end, out);
1764 std::copy(s_itr,s_end,out);
1782 template <
typename Iterator>
1783 inline bool match(
const Iterator pattern_begin,
1784 const Iterator pattern_end,
1785 const Iterator data_begin,
1786 const Iterator data_end,
1787 const typename std::iterator_traits<Iterator>::value_type& zero_or_more,
1788 const typename std::iterator_traits<Iterator>::value_type& zero_or_one)
1795 Iterator d_itr = data_begin;
1796 Iterator p_itr = pattern_begin;
1797 Iterator c_itr = data_begin;
1798 Iterator m_itr = data_begin;
1800 while ((data_end != d_itr) && (zero_or_more != (*p_itr)))
1802 if (((*p_itr) != (*d_itr)) && (zero_or_one != (*p_itr)))
1810 while (data_end != d_itr)
1812 if (zero_or_more == (*p_itr))
1814 if (pattern_end == (++p_itr))
1822 else if (((*p_itr) == (*d_itr)) || (zero_or_one == (*p_itr)))
1834 while ((p_itr != pattern_end) && (zero_or_more == (*p_itr))) ++p_itr;
1836 return (p_itr == pattern_end);
1846 return match(wild_card.data(),
1847 wild_card.data() + wild_card.size(),
1849 str.data() + str.size(),
1856 return std::toupper(c1) == std::toupper(c2);
1859 template <
typename InputIterator>
1860 inline bool imatch(
const InputIterator begin1,
const InputIterator end1,
1861 const InputIterator begin2,
const InputIterator end2)
1869 InputIterator itr1 = begin1;
1870 InputIterator itr2 = begin2;
1872 while (end1 != itr1)
1875 if (std::toupper(*itr1) != std::toupper(*itr2))
1886 template <
typename T>
1895 s1.data() + s1.size(),
1897 s2.data() + s2.size());
1900 template <
typename Iterator>
1903 for (
const std::string* itr = begin; end != itr; ++itr)
1913 template <
typename Allocator,
1914 template <
typename,
typename>
class Sequence>
1917 return (sequence.end() !=
imatch(s,sequence.begin(),sequence.end()));
1920 template <
typename Comparator,
typename Allocator>
1923 return imatch(s,set.begin(),set.end());
1926 template <
typename Comparator,
typename Allocator>
1927 inline bool imatch(
const std::string& s,
const std::multiset<std::string,Comparator,Allocator>& multiset)
1929 return imatch(s,multiset.begin(),multiset.end());
1932 template <
typename Iterator,
typename OutputIterator>
1933 inline std::size_t
find_all(
const Iterator pattern_begin,
1934 const Iterator pattern_end,
1935 const Iterator begin,
1939 Iterator itr = begin;
1940 const std::size_t pattern_length =
std::distance(pattern_begin,pattern_end);
1941 std::size_t match_count = 0;
1942 while (end != (itr = std::search(itr, end, pattern_begin, pattern_end)))
1945 itr += pattern_length;
1952 template <
typename Iterator,
1955 template <
typename,
typename>
class Sequence>
1956 inline std::size_t
find_all(
const Iterator pattern_begin,
1957 const Iterator pattern_end,
1958 const Iterator begin,
1960 Sequence<Range,Allocator>& seq)
1962 return find_all(pattern_begin,pattern_end,begin,end,std::back_inserter(seq));
1967 if (pattern.size() > data.size())
1968 return std::string::npos;
1969 const char* result_itr = std::search(data.data(),data.data() + data.size(),
1970 pattern.data(), pattern.data() + pattern.size(),
1972 if ((data.data() + data.size()) == result_itr)
1973 return std::string::npos;
1978 template <
typename Iterator,
typename OutputIterator>
1980 const Iterator pattern_end,
1981 const Iterator begin,
1985 Iterator itr = begin;
1986 const std::size_t pattern_length =
std::distance(pattern_begin,pattern_end);
1987 std::size_t match_count = 0;
1989 while (end != (itr = std::search(itr, end, pattern_begin, pattern_end,
imatch_char)))
1992 itr += pattern_length;
2000 template <
typename OutputIterator>
2005 return find_all(pattern.data(), pattern.data() + pattern.size(),
2006 data.data(), data.data() + data.size(),
2010 template <
typename Range,
2012 template <
typename,
typename>
class Sequence>
2015 Sequence<Range,Allocator>& seq)
2017 return find_all(pattern,data,std::back_inserter(seq));
2020 template <
typename OutputIterator>
2025 return ifind_all(pattern.data(), pattern.data() + pattern.size(),
2026 data.data(), data.data() + data.size(),
2030 template <
typename Range,
2032 template <
typename,
typename>
class Sequence>
2035 Sequence<Range,Allocator>& seq)
2037 return ifind_all(pattern,data,std::back_inserter(seq));
2040 template <
typename InputIterator>
2042 const InputIterator pattern_end,
2043 const InputIterator begin,
2044 const InputIterator end)
2049 return std::equal(pattern_begin,pattern_end,begin);
2057 if (pattern.size() <= data.size())
2060 pattern.data() + pattern.size(),
2062 data.data() + data.size());
2068 template <
typename InputIterator>
2070 const InputIterator pattern_end,
2071 const InputIterator begin,
2072 const InputIterator end)
2077 return std::equal(pattern_begin,pattern_end,begin,
imatch_char);
2085 if (pattern.size() <= data.size())
2088 pattern.data() + pattern.size(),
2090 data.data() + data.size());
2096 template <
typename InputIterator>
2098 const InputIterator pattern_end,
2099 const InputIterator begin,
2100 const InputIterator end)
2103 const std::size_t pattern_length =
std::distance(pattern_begin,pattern_end);
2105 if (pattern_length <= data_length)
2107 return std::equal(pattern_begin,
2109 begin + (data_length - pattern_length));
2117 if (pattern.size() <= data.size())
2120 pattern.data() + pattern.size(),
2122 data.data() + data.size());
2128 template <
typename InputIterator>
2130 const InputIterator pattern_end,
2131 const InputIterator begin,
2132 const InputIterator end)
2135 const std::size_t pattern_length =
std::distance(pattern_begin,pattern_end);
2137 if (pattern_length <= data_length)
2139 return std::equal(pattern_begin,
2141 begin + (data_length - pattern_length),
2150 if (pattern.size() <= data.size())
2153 pattern.data() + pattern.size(),
2155 data.data() + data.size());
2163 if (pattern.empty())
2164 return std::string::npos;
2165 else if (data.empty())
2166 return std::string::npos;
2167 else if (pattern.size() > data.size())
2168 return std::string::npos;
2169 const char* itr = std::search(data.data(),
2170 data.data() + data.size(),
2172 pattern.data() + pattern.size());
2173 return ((data.data() + data.size()) == itr) ? std::string::npos :
std::distance(data.data(),itr);
2176 namespace tokenize_options
2187 static inline bool perform_compress_delimiters(
const type& split_opt)
2192 static inline bool perform_include_1st_delimiter(
const type& split_opt)
2197 static inline bool perform_include_all_delimiters(
const type& split_opt)
2204 template <
typename Iterator,
typename DelimiterPredicate>
2209 template <
typename Iterartor,
2211 typename T = std::pair<Iterator,Iterator> >
2212 class tokenizer_iterator :
public std::iterator<std::forward_iterator_tag,T>
2218 typedef typename std::pair<iterator,iterator> range_type;
2226 : predicate_(predicate),
2228 range_(begin,begin),
2229 current_token_(end,end),
2230 compress_delimiters_(tokenize_options::perform_compress_delimiters(tokenize_option)),
2231 include_1st_delimiter_(tokenize_options::perform_include_1st_delimiter(tokenize_option)),
2232 include_all_delimiters_(tokenize_options::perform_include_all_delimiters(tokenize_option)),
2233 include_delimiters_(include_1st_delimiter_ || include_all_delimiters_),
2234 last_token_done_(
false)
2242 inline tokenizer_iterator& operator++()
2244 if (last_token_done_)
2246 range_.first = range_.second;
2249 else if (end_ != range_.second)
2251 range_.first = range_.second;
2254 while (end_ != range_.second)
2256 if (predicate_(*(range_.second)))
2258 if (include_delimiters_)
2260 if (include_1st_delimiter_)
2262 else if (include_all_delimiters_)
2263 while ((end_ != range_.second) && predicate_(*(range_.second))) ++range_.second;
2264 current_token_ = range_;
2265 if ((!include_all_delimiters_) && compress_delimiters_)
2266 while ((end_ != range_.second) && predicate_(*(range_.second))) ++range_.second;
2270 current_token_ = range_;
2271 if (compress_delimiters_)
2272 while ((end_ != (++range_.second)) && predicate_(*(range_.second))) ;
2282 if (range_.first != range_.second)
2284 current_token_.second = range_.second;
2285 if (!last_token_done_)
2287 if (predicate_(*(range_.second - 1)))
2288 current_token_.first = range_.second;
2290 current_token_.first = range_.first;
2291 last_token_done_ =
true;
2294 range_.first = range_.second;
2300 inline tokenizer_iterator operator++(
int)
2302 tokenizer_iterator tmp = (*this);
2307 inline tokenizer_iterator& operator+=(
const int inc)
2311 for (
int i = 0; i <
inc; ++i, ++(*this)) ;
2318 return current_token_;
2323 return std::string(current_token_.first,current_token_.second);
2326 inline bool operator==(
const tokenizer_iterator& itr)
const
2328 return (range_ == itr.range_) && (end_ == itr.end_);
2331 inline bool operator!=(
const tokenizer_iterator& itr)
const
2333 return (range_ != itr.range_) || (end_ != itr.end_);
2336 inline tokenizer_iterator&
operator=(
const tokenizer_iterator& itr)
2340 range_ = itr.range_;
2341 current_token_ = itr.current_token_;
2343 compress_delimiters_ = itr.compress_delimiters_;
2344 include_1st_delimiter_ = itr.include_1st_delimiter_;
2345 include_all_delimiters_ = itr.include_all_delimiters_;
2346 include_delimiters_ = itr.include_delimiters_;
2347 last_token_done_ = itr.last_token_done_;
2359 const Predicate& predicate_;
2362 range_type current_token_;
2363 bool compress_delimiters_;
2364 bool include_1st_delimiter_;
2365 bool include_all_delimiters_;
2366 bool include_delimiters_;
2367 bool last_token_done_;
2372 typedef typename std::iterator_traits<Iterator>::value_type
value_type;
2374 typedef tokenizer_iterator<Iterator,DelimiterPredicate>
iterator;
2383 : tokenize_options_(tokenize_options),
2384 predicate_(predicate),
2387 begin_itr_(begin_,end_,predicate_,tokenize_options_),
2388 end_itr_(end_,end_,predicate_,tokenize_options_)
2394 : tokenize_options_(tokenize_options),
2395 predicate_(predicate),
2397 end_(s.data() + s.size()),
2398 begin_itr_(begin_,end_,predicate_,tokenize_options_),
2399 end_itr_(end_,end_,predicate_,tokenize_options_)
2408 end_itr_ = t.end_itr_;
2409 begin_itr_ = t.begin_itr_;
2410 tokenize_options_ = t.tokenize_options_;
2417 assign(s.data(),s.data() + s.size());
2422 assign(s.data(),s.data() + s.size());
2429 begin_itr_ =
iterator(begin_,end_,predicate_,tokenize_options_);
2430 end_itr_ =
iterator(end_,end_,predicate_,tokenize_options_);
2446 const DelimiterPredicate& predicate_;
2453 namespace std_string
2455 template <
typename DelimiterPredicate = single_delimiter_predicate<std::
string::value_type> >
2474 template <
typename Sequence>
2486 : sequence_(sequence)
2490 : sequence_(it.sequence_)
2497 this->sequence_ = it.sequence_;
2502 template <
typename Iterator>
2507 sequence_.push_back(t);
2515 sequence_.push_back(t);
2519 template <
typename Iterator>
2520 inline void operator()(
const std::pair<Iterator,Iterator>& r)
const
2524 sequence_.push_back(t);
2527 template <
typename Iterator>
2530 sequence_.push_back(string_to_type_converter<value_type>(begin,end));
2550 Sequence& sequence_;
2553 template <
typename Sequence>
2559 template <
typename Set>
2582 this->set_ = it.set_;
2587 template <
typename Iterator>
2596 template <
typename Iterator>
2624 template <
typename Set>
2630 template <
typename Container>
2642 : container_(container)
2646 : container_(it.container_)
2653 this->container_ = it.container_;
2658 template <
typename Iterator>
2667 template <
typename Iterator>
2692 Container& container_;
2695 template <
typename Container>
2701 template <
typename Sequence>
2703 typename Sequence::value_type,
2711 : sequence_(sequence)
2715 : sequence_(it.sequence_)
2722 this->sequence_ = it.sequence_;
2729 sequence_.push_back(v);
2735 sequence_.push_back(v);
2755 Sequence& sequence_;
2758 template <
typename Sequence>
2764 template <
typename Set>
2766 typename Set::value_type,
2785 this->set_ = itr.set_;
2821 template <
typename Set>
2827 template <
typename Container>
2837 : container_(container)
2844 this->container_ = itr.container_;
2872 Container& container_;
2875 template <
typename Container>
2881 template <
typename T>
2893 : pointer_(pointer),
2894 insert_count_(insert_count)
2898 : pointer_(it.pointer_)
2905 this->pointer_ = it.pointer_;
2910 template <
typename Iterator>
2935 template <
typename Iterator>
2936 inline void operator()(
const std::pair<Iterator,Iterator>& r)
const
2947 template <
typename Iterator>
2950 (*pointer_) = string_to_type_converter<T>(begin,end);
2973 std::size_t& insert_count_;
2976 template <
typename T>
2982 template <
typename T>
2985 static std::size_t insert_count = 0;
2989 template <
typename T>
3003 : counter_(itr.counter_)
3010 this->counter_ = itr.counter_;
3043 std::size_t& counter_;
3046 template <
typename T>
3052 template <
typename Function>
3062 : function_(function)
3066 : function_(it.function_)
3073 this->function_ = it.function_;
3078 template <
typename T>
3085 template <
typename T>
3111 template <
typename Function>
3117 namespace split_options
3128 static inline bool perform_compress_delimiters(
const type& split_opt)
3133 static inline bool perform_include_1st_delimiter(
const type& split_opt)
3138 static inline bool perform_include_all_delimiters(
const type& split_opt)
3145 template <
typename DelimiterPredicate,
3148 inline std::size_t
split(
const DelimiterPredicate& delimiter,
3149 const Iterator begin,
3154 if (begin == end)
return 0;
3155 std::size_t token_count = 0;
3156 std::pair<Iterator,Iterator> range(begin,begin);
3157 const bool compress_delimiters = split_options::perform_compress_delimiters(split_option);
3162 while (end != range.second)
3164 if (delimiter(*range.second))
3166 if (include_delimiters)
3168 if (include_1st_delimiter)
3170 else if (include_all_delimiters)
3171 while ((end != range.second) && delimiter(*range.second)) ++range.second;
3175 while ((end != range.second) && delimiter(*range.second)) ++range.second;
3181 if (compress_delimiters)
3182 while ((end != (++range.second)) && delimiter(*range.second)) ;
3187 range.first = range.second;
3193 if ((range.first != range.second) || delimiter(*(range.second - 1)))
3203 template <
typename DelimiterPredicate,
3206 inline std::size_t
split(
const DelimiterPredicate& delimiter,
3207 const std::pair<Iterator,Iterator>& range,
3211 return split(delimiter,
3212 range.first,range.second,
3217 template <
typename DelimiterPredicate,
3220 inline std::size_t
split(
const char* delimiters,
3221 const std::pair<Iterator,Iterator>& range,
3227 range.first,range.second,
3232 range.first,range.second,
3237 template <
typename DelimiterPredicate,
3241 const std::pair<Iterator,Iterator>& range,
3245 if (1 == delimiters.size())
3247 range.first,range.second,
3252 range.first,range.second,
3257 template <
typename OutputIterator>
3258 inline std::size_t
split(
const char* delimiters,
3265 str.data(), str.data() + str.size(),
3270 str.data(), str.data() + str.size(),
3275 template <
typename OutputIterator>
3281 if (1 == delimiters.size())
3283 str.data(), str.data() + str.size(),
3288 str.data(), str.data() + str.size(),
3293 template <
typename OutputIterator>
3294 inline std::size_t
split(
const std::string::value_type delimiter,
3300 str.data(), str.data() + str.size(),
3305 template <
typename Allocator,
3306 template <
typename,
typename>
class Sequence>
3307 inline std::size_t
split(
const char* delimiters,
3309 Sequence<std::pair<const char*, const char*>,Allocator>& sequence,
3314 str.data(), str.data() + str.size(),
3315 std::back_inserter(sequence),
3319 str.data(), str.data() + str.size(),
3320 std::back_inserter(sequence),
3324 template <
typename Allocator,
3325 template <
typename,
typename>
class Sequence>
3328 Sequence<std::pair<const char*, const char*>,Allocator>& sequence,
3331 if (1 == delimiters.size())
3333 str.data(), str.data() + str.size(),
3334 std::back_inserter(sequence),
3338 str.data(), str.data() + str.size(),
3339 std::back_inserter(sequence),
3343 template <
typename DelimiterPredicate,
3345 inline std::size_t
split(
const DelimiterPredicate& delimiter,
3350 return split(delimiter,
3351 str.data(), str.data() + str.size(),
3356 template <
typename DelimiterPredicate,
3359 inline std::size_t
split_n(
const DelimiterPredicate& delimiter,
3360 const Iterator begin,
3362 const std::size_t& token_count,
3366 if (0 == token_count)
return 0;
3367 if (begin == end)
return 0;
3368 std::size_t match_count = 0;
3369 std::pair<Iterator,Iterator> range(begin,begin);
3370 const bool compress_delimiters = split_options::perform_compress_delimiters(split_option);
3375 while (end != range.second)
3377 if (delimiter(*range.second))
3379 if (include_delimiters)
3384 if (++match_count >= token_count)
3386 if (compress_delimiters)
3387 while ((end != range.second) && delimiter(*range.second)) ++range.second;
3393 if (++match_count >= token_count)
3395 if (compress_delimiters)
3396 while ((end != (++range.second)) && delimiter(*range.second)) ;
3400 range.first = range.second;
3406 if ((range.first != range.second) || delimiter(*(range.second - 1)))
3416 template <
typename OutputIterator>
3417 inline std::size_t
split_n(
const char* delimiters,
3419 const std::size_t& token_count,
3424 str.data(), str.data() + str.size(),
3430 template <
typename OutputIterator>
3433 const std::size_t& token_count,
3437 if (1 == delimiters.size())
3439 str.data(), str.data() + str.size(),
3445 str.data(), str.data() + str.size(),
3451 template <
typename InputIterator,
typename OutputIterator>
3453 const InputIterator begin,
3454 const InputIterator end,
3455 const std::size_t& token_count,
3460 if (1 == delimiters.size())
3474 template <
typename OutputIterator>
3475 inline std::size_t
split_n(
const std::string::value_type delimiter,
3477 const std::size_t& token_count,
3482 str.data(),str.data() + str.size(),
3488 template <
typename DelimiterPredicate,
3490 inline std::size_t
split_n(
const DelimiterPredicate& delimiter,
3492 const std::size_t& token_count,
3497 str.data(),str.data() + str.size(),
3503 #ifdef strtk_enable_regex
3505 static const std::string uri_expression (
"((https?|ftp)\\://((\\[?(\\d{1,3}\\.){3}\\d{1,3}\\]?)|(([-a-zA-Z0-9]+\\.)+[a-zA-Z]{2,4}))(\\:\\d+)?(/[-a-zA-Z0-9._?,+&%$#=~\\\\]+)*/?)");
3506 static const std::string email_expression (
"([\\w\\-\\.]+)@((\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\])|(([\\w\\-]+\\.)+)([a-zA-Z]{2,4}))");
3507 static const std::string ip_expression (
"(([0-2]*[0-9]+[0-9]+)\\.([0-2]*[0-9]+[0-9]+)\\.([0-2]*[0-9]+[0-9]+)\\.([0-2]*[0-9]+[0-9]+))");
3508 static const std::string ieee754_expression (
"([-+]?((\\.[0-9]+|[0-9]+\\.[0-9]+)([eE][-+][0-9]+)?|[0-9]+))");
3510 namespace regex_match_mode
3527 template <
typename InputIterator,
typename OutputIterator>
3528 inline std::size_t
split_regex(
const boost::regex& delimiter_expression,
3529 const InputIterator begin,
3530 const InputIterator end,
3534 boost::regex_iterator<InputIterator> itr(begin,end,delimiter_expression);
3535 boost::regex_iterator<InputIterator> itr_end;
3536 std::pair<InputIterator,InputIterator> range(begin,begin);
3537 std::size_t match_count = 0;
3538 while (itr_end != itr)
3540 range.first = (*itr)[mode].first;
3541 range.second = (*itr)[mode].second;
3550 template <
typename InputIterator,
typename OutputIterator>
3552 const InputIterator begin,
3553 const InputIterator end,
3557 const boost::regex regex_expression(delimiter_expression);
3564 template <
typename OutputIterator>
3571 text.begin(),text.end(),
3576 template <
typename OutputIterator>
3577 inline std::size_t
split_regex(
const boost::regex& delimiter_expression,
3583 text.begin(),text.end(),
3588 template <
typename InputIterator,
typename OutputIterator>
3590 const InputIterator begin,
3591 const InputIterator end,
3592 const std::size_t& token_count,
3596 boost::sregex_iterator itr(begin,end,delimiter_expression);
3597 const boost::sregex_iterator itr_end;
3598 std::pair<InputIterator,InputIterator> range(begin,begin);
3599 std::size_t match_count = 0;
3600 while (itr_end != itr)
3602 range.first = (*itr)[mode].first;
3603 range.second = (*itr)[mode].second;
3607 if (++match_count >= token_count)
3613 template <
typename InputIterator,
typename OutputIterator>
3615 const InputIterator begin,
3616 const InputIterator end,
3617 const std::size_t& token_count,
3621 const boost::regex regex_expression(delimiter_expression);
3629 template <
typename OutputIterator>
3632 const std::size_t& token_count,
3637 text.begin(),text.end(),
3643 template <
typename OutputIterator>
3646 const std::size_t& token_count,
3651 text.begin(),text.end(),
3657 #endif // strtk_enable_regex
3659 template <const std::
size_t offset_list_size>
3668 std::copy(offset_list, offset_list + offset_list_size, offset_list_);
3669 offset_list_[offset_list_size] = 0;
3674 return (0 == offset_list_size);
3684 return offset_list_size;
3689 int result = offset_list_[current_index_++];
3690 if (rotate_ && (current_index_ >= offset_list_size))
3700 mutable std::size_t current_index_;
3701 int offset_list_[offset_list_size + 1];
3705 const int& v4,
const int& v5,
const int& v6,
3706 const int& v7,
const int& v8,
const int& v9,
3707 const int& v10,
const int& v11,
const int& v12,
3708 const bool& rotate =
false)
3710 const int offset_list[12] = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 };
3715 const int& v4,
const int& v5,
const int& v6,
3716 const int& v7,
const int& v8,
const int& v9,
3717 const int& v10,
const int& v11,
3718 const bool& rotate =
false)
3720 const int offset_list[11] = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 };
3725 const int& v4,
const int& v5,
const int& v6,
3726 const int& v7,
const int& v8,
const int& v9,
3727 const int& v10,
const bool& rotate =
false)
3729 const int offset_list[10] = { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 };
3734 const int& v4,
const int& v5,
const int& v6,
3735 const int& v7,
const int& v8,
const int& v9,
3736 const bool& rotate =
false)
3738 const int offset_list[9] = { v1, v2, v3, v4, v5, v6, v7, v8, v9 };
3743 const int& v4,
const int& v5,
const int& v6,
3744 const int& v7,
const int& v8,
const bool& rotate =
false)
3746 const int offset_list[8] = { v1, v2, v3, v4, v5, v6, v7, v8 };
3751 const int& v4,
const int& v5,
const int& v6,
3752 const int& v7,
const bool& rotate =
false)
3754 const int offset_list[7] = { v1, v2, v3, v4, v5, v6, v7 };
3759 const int& v4,
const int& v5,
const int& v6,
3760 const bool& rotate =
false)
3762 const int offset_list[6] = { v1, v2, v3, v4, v5, v6 };
3767 const int& v4,
const int& v5,
const bool& rotate =
false)
3769 const int offset_list[5] = { v1, v2, v3, v4, v5 };
3774 const int& v4,
const bool& rotate =
false)
3776 const int offset_list[4] = { v1, v2, v3, v4 };
3781 const bool& rotate =
false)
3783 const int offset_list[3] = { v1, v2, v3 };
3789 const int offset_list[2] = { v1, v2 };
3794 const bool& rotate =
false)
3796 const int offset_list[1] = { v1 };
3800 template <
typename OffsetPredicate,
3801 typename InputIterator,
3804 const InputIterator end,
3805 const OffsetPredicate& offset,
3808 std::size_t length = 0;
3810 std::pair<InputIterator,InputIterator> range(begin,begin);
3811 std::size_t match_count = 0;
3812 int offset_length = 0;
3813 std::size_t increment_amount = 0;
3814 while ((end != range.second) && (0 < (offset_length = offset.next())))
3816 increment_amount = std::min<std::size_t>(length,offset_length);
3817 range.first = range.second;
3818 range.second += increment_amount;
3819 length -= increment_amount;
3827 template <
typename OffsetPredicate,
3830 const OffsetPredicate& offset,
3833 return offset_splitter(str.data(),str.data() + str.size(),offset,out);
3836 template <
typename InputIterator,
3838 typename OutputPair>
3840 const InputIterator end,
3841 const Predicate& delimiter,
3847 InputIterator itr = begin;
3851 if (delimiter(*itr))
3872 std::pair<const char*,const char*>& v1,
3873 std::pair<const char*,const char*>& v2)
3876 str.data() + str.size(),
3882 template <
typename DelimiterPredicate>
3885 std::pair<const char*,const char*>& v1,
3886 std::pair<const char*,const char*>& v2)
3889 str.data() + str.size(),
3895 template <
typename Function>
3900 return split(delimiters,
3902 strtk::functional_inserter<Function>(
function));
3905 template <
typename Function>
3907 const char* delimiters,
3910 return split(delimiters,
3912 strtk::functional_inserter<Function>(
function));
3915 template <
typename InputIterator>
3919 InputIterator prev = begin;
3920 InputIterator itr = begin;
3921 std::size_t count = 0;
3922 while (end != ++itr)
3924 if ((*prev) == (*itr))
3932 template <
typename T,
3934 template <
typename,
typename>
class Sequence>
3937 return (*std::min_element(sequence.begin(),sequence.end()));
3940 template <
typename T,
3941 typename Comparator,
3945 return (*set.begin());
3948 template <
typename T,
3949 typename Comparator,
3951 inline T min_of_cont(
const std::multiset<T,Comparator,Allocator>& multiset)
3953 return (*multiset.begin());
3956 template <
typename T,
3958 template <
typename,
typename>
class Sequence>
3961 return (*std::max_element(sequence.begin(),sequence.end()));
3964 template <
typename T,
3965 typename Comparator,
3969 return (*set.rbegin());
3972 template <
typename T,
3973 typename Comparator,
3975 inline T max_of_cont(
const std::multiset<T,Comparator,Allocator>& multiset)
3977 return (*multiset.rbegin());
3980 template <
typename InputIterator>
3982 typename std::iterator_traits<InputIterator>::value_type& min_value,
3983 typename std::iterator_traits<InputIterator>::value_type& max_value)
3987 InputIterator itr = begin;
3988 while (end != ++itr)
3990 if (*itr < min_value)
3992 else if (*itr > max_value)
3997 template <
typename T,
3999 template <
typename,
typename>
class Sequence>
4009 template <
typename T,
4010 typename Comparator,
4016 min_value = (*set.begin());
4017 max_value = (*set.rbegin());
4020 template <
typename T,
4021 typename Comparator,
4027 min_value = (*multiset.begin());
4028 max_value = (*multiset.rbegin());
4031 template <
typename Iterator>
4034 typedef typename std::iterator_traits<Iterator>::value_type
type;
4035 typedef typename std::pair<Iterator,Iterator> iter_type;
4036 typedef typename std::list<iter_type> itr_list_type;
4037 itr_list_type itr_list;
4039 type smallest = (*std::min_element(begin,end));
4041 for (Iterator itr = begin; itr != end; ++itr)
4043 if (*itr == smallest) itr_list.push_back(
std::make_pair(itr,itr));
4046 while (itr_list.size() > 1)
4048 typename itr_list_type::iterator itr = itr_list.begin();
4049 while (itr_list.end() != itr)
4052 if (end == (*itr).first)
4053 itr = itr_list.erase(itr);
4058 smallest = *(*itr_list.begin()).first;
4060 for (itr = (++itr_list.begin()); itr != itr_list.end(); ++itr)
4062 if (*(*itr).first < smallest)
4064 smallest = *(*itr).first;
4068 itr = itr_list.begin();
4069 while (itr_list.end() != itr)
4071 if (*(*itr).first != smallest)
4072 itr = itr_list.erase(itr);
4077 itr = itr_list.begin();
4078 while (itr_list.end() != itr)
4080 if (end == (*itr).first)
4081 itr = itr_list.erase(itr);
4088 std::rotate(begin,(*itr_list.begin()).second,end);
4094 const_cast<char*>(str.data() + str.size()));
4097 template <
typename T,
4099 template <
typename,
typename>
class Sequence>
4107 static const std::size_t lut_size = 256;
4108 unsigned long long int lut[lut_size];
4110 std::fill_n(lut,lut_size,std::numeric_limits<unsigned long long int>::max());
4112 static const unsigned long long int not_yet_encountered = std::numeric_limits<unsigned long long int>::max();
4113 static const unsigned long long int repeated = not_yet_encountered - 1;
4115 const char* itr = begin;
4116 unsigned long long int position = 0;
4119 unsigned long long int& element = lut[
static_cast<unsigned int>(*itr)];
4120 if (not_yet_encountered == element)
4124 else if (element < repeated)
4132 position = repeated;
4134 for (std::size_t i = 0; i < lut_size; ++i)
4136 if (lut[i] < position)
4140 return (repeated != position) ? (begin + position) : end;
4145 char * b =
reinterpret_cast<char*
>(
const_cast<unsigned char*
>(begin));
4146 char * e =
reinterpret_cast<char*
>(
const_cast<unsigned char*
>(end));
4147 return const_cast<const unsigned char*
>(
reinterpret_cast<unsigned char*
>(
const_cast<char*
>(
first_non_repeated_char(b,e))));
4153 return static_cast<std::size_t>(std::string::npos);
4155 if ((str.data() + str.size()) != itr)
4156 return static_cast<std::size_t
>(itr - str.data());
4158 return static_cast<std::size_t
>(std::string::npos);
4163 static const unsigned short hex_lut[] =
4165 0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730,
4166 0x3830, 0x3930, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530, 0x4630,
4167 0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731,
4168 0x3831, 0x3931, 0x4131, 0x4231, 0x4331, 0x4431, 0x4531, 0x4631,
4169 0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732,
4170 0x3832, 0x3932, 0x4132, 0x4232, 0x4332, 0x4432, 0x4532, 0x4632,
4171 0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733,
4172 0x3833, 0x3933, 0x4133, 0x4233, 0x4333, 0x4433, 0x4533, 0x4633,
4173 0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734,
4174 0x3834, 0x3934, 0x4134, 0x4234, 0x4334, 0x4434, 0x4534, 0x4634,
4175 0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735,
4176 0x3835, 0x3935, 0x4135, 0x4235, 0x4335, 0x4435, 0x4535, 0x4635,
4177 0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736,
4178 0x3836, 0x3936, 0x4136, 0x4236, 0x4336, 0x4436, 0x4536, 0x4636,
4179 0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737,
4180 0x3837, 0x3937, 0x4137, 0x4237, 0x4337, 0x4437, 0x4537, 0x4637,
4181 0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738,
4182 0x3838, 0x3938, 0x4138, 0x4238, 0x4338, 0x4438, 0x4538, 0x4638,
4183 0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739,
4184 0x3839, 0x3939, 0x4139, 0x4239, 0x4339, 0x4439, 0x4539, 0x4639,
4185 0x3041, 0x3141, 0x3241, 0x3341, 0x3441, 0x3541, 0x3641, 0x3741,
4186 0x3841, 0x3941, 0x4141, 0x4241, 0x4341, 0x4441, 0x4541, 0x4641,
4187 0x3042, 0x3142, 0x3242, 0x3342, 0x3442, 0x3542, 0x3642, 0x3742,
4188 0x3842, 0x3942, 0x4142, 0x4242, 0x4342, 0x4442, 0x4542, 0x4642,
4189 0x3043, 0x3143, 0x3243, 0x3343, 0x3443, 0x3543, 0x3643, 0x3743,
4190 0x3843, 0x3943, 0x4143, 0x4243, 0x4343, 0x4443, 0x4543, 0x4643,
4191 0x3044, 0x3144, 0x3244, 0x3344, 0x3444, 0x3544, 0x3644, 0x3744,
4192 0x3844, 0x3944, 0x4144, 0x4244, 0x4344, 0x4444, 0x4544, 0x4644,
4193 0x3045, 0x3145, 0x3245, 0x3345, 0x3445, 0x3545, 0x3645, 0x3745,
4194 0x3845, 0x3945, 0x4145, 0x4245, 0x4345, 0x4445, 0x4545, 0x4645,
4195 0x3046, 0x3146, 0x3246, 0x3346, 0x3446, 0x3546, 0x3646, 0x3746,
4196 0x3846, 0x3946, 0x4146, 0x4246, 0x4346, 0x4446, 0x4546, 0x4646
4199 for (
const unsigned char* itr = begin; end != itr; ++itr)
4201 *
reinterpret_cast<unsigned short*
>(out) = hex_lut[(*itr)];
4202 out +=
sizeof(
unsigned short);
4209 reinterpret_cast<const unsigned char*>(end),
4210 reinterpret_cast<unsigned char*>(out));
4218 inline void convert_bin_to_hex(
const std::pair<const unsigned char*,const unsigned char*>& r,
unsigned char* out)
4230 output.resize(binary_data.size() * 2);
4232 binary_data.data() + binary_data.size(),
4233 const_cast<char*
>(output.data()));
4248 else if (1 == (length % 2))
4250 static const unsigned char hex_to_bin[] =
4252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4258 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4259 0x08, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4260 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
4261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4264 0x00, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00,
4265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4286 const unsigned char* itr = begin;
4289 *
reinterpret_cast<unsigned char*
>(out) = static_cast<unsigned char>(hex_to_bin[itr[0]] << 4 | hex_to_bin[itr[1]]);
4299 reinterpret_cast<const unsigned char*>(end),
4300 reinterpret_cast<unsigned char*>(out));
4308 inline bool convert_hex_to_bin(
const std::pair<const unsigned char*,const unsigned char*>& r,
unsigned char* out)
4325 if (hex_data.empty() || (1 == (hex_data.size() % 2)))
4327 output.resize(hex_data.size() >> 1);
4329 hex_data.data() + hex_data.size(),
4330 const_cast<char*
>(output.data()));
4335 static const unsigned char bin_to_base64 [] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4338 std::size_t rounds = length / 3;
4339 const unsigned char* itr = begin;
4340 for (std::size_t i = 0; i < rounds; ++i)
4342 unsigned int block = *(itr++) << 16;
4343 block |= *(itr++) << 8;
4345 *(out++) = bin_to_base64[( block >> 18 ) & 0x3F];
4346 *(out++) = bin_to_base64[( block >> 12 ) & 0x3F];
4347 *(out++) = bin_to_base64[( block >> 6 ) & 0x3F];
4348 *(out++) = bin_to_base64[( block ) & 0x3F];
4351 if ((rounds = (length % 3)) > 0)
4356 unsigned int block = (
unsigned char) (*itr) << 16;
4357 *(out++) = bin_to_base64[( block >> 18 ) & 0x3F];
4358 *(out++) = bin_to_base64[( block >> 12 ) & 0x3F];
4365 unsigned int block = *(itr++) << 16;
4366 block |= *(itr++) << 8;
4367 *(out++) = bin_to_base64[( block >> 18 ) & 0x3F];
4368 *(out++) = bin_to_base64[( block >> 12 ) & 0x3F];
4369 *(out++) = bin_to_base64[( block >> 6 ) & 0x3F];
4375 return static_cast<std::size_t
>((length / 3) * 4) + ((length % 3) > 0 ? 4 : 0);
4381 reinterpret_cast<const unsigned char*>(end),
4382 reinterpret_cast<unsigned char*>(out));
4387 output.resize(std::max<std::size_t>(4,binary_data.size() << 1));
4389 binary_data.data() + binary_data.size(),
4390 const_cast<char*
>(output.data()));
4391 output.resize(resize);
4396 static const unsigned char base64_to_bin[] =
4398 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4399 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4400 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4401 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4402 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4403 0xFF, 0xFF, 0xFF, 0x3E, 0xFF, 0xFF, 0xFF, 0x3F,
4404 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
4405 0x3C, 0x3D, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4406 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
4407 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
4408 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
4409 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4410 0xFF, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
4411 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
4412 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
4413 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4414 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4415 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4416 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4417 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4418 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4419 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4420 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4421 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4422 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4423 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4424 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4425 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4426 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4427 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4428 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
4429 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
4432 const unsigned char* end_itr = end;
4434 if (
'=' == *(end - 2))
4436 else if (
'=' == *(end - 1))
4440 const std::size_t rounds = length / 4;
4441 const unsigned char* itr = begin;
4443 for (std::size_t i = 0; i < rounds; ++i)
4445 unsigned int block = base64_to_bin[*(itr++)] << 18;
4446 block |= base64_to_bin[*(itr++)] << 12;
4447 block |= base64_to_bin[*(itr++)] << 6;
4448 block |= base64_to_bin[*(itr++)];
4450 *(out++) = static_cast<unsigned char>(( block >> 16 ) & 0xFF);
4451 *(out++) = static_cast<unsigned char>(( block >> 8 ) & 0xFF);
4452 *(out++) = static_cast<unsigned char>(( block ) & 0xFF);
4455 const std::size_t remainder = (length % 4);
4461 unsigned int block = base64_to_bin[*(itr++)] << 18;
4462 block |= base64_to_bin[*(itr++)] << 12;
4463 (*out) =
static_cast<unsigned char>(( block >> 16 ) & 0xFF);
4468 unsigned int block = base64_to_bin[*(itr++)] << 18;
4469 block |= base64_to_bin[*(itr++)] << 12;
4470 block |= base64_to_bin[*(itr++)] << 6;
4471 *(out++) = static_cast<unsigned char>(( block >> 16 ) & 0xFF);
4472 *(out ) = static_cast<unsigned char>(( block >> 8 ) & 0xFF);
4478 return static_cast<std::size_t
>((3 * length) / 4);
4484 reinterpret_cast<const unsigned char*>(end),
4485 reinterpret_cast<unsigned char*>(out));
4490 output.resize(binary_data.size());
4492 binary_data.data() + binary_data.size(),
4493 const_cast<char*
>(output.data()));
4494 output.resize(resize);
4499 static const unsigned char printable_char_table[] =
4501 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4502 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4503 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4504 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4505 0x2E, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
4506 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
4507 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
4508 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
4509 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
4510 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
4511 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
4512 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
4513 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
4514 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
4515 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
4516 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x2E,
4517 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4518 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4519 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4520 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4521 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4522 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4523 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4524 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4525 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4526 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4527 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4528 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4529 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4530 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4531 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,
4532 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E
4534 unsigned char* itr = begin;
4537 (*itr) = printable_char_table[
static_cast<unsigned int>((*itr))];
4545 reinterpret_cast<unsigned char*>(end));
4551 reinterpret_cast<unsigned char*
>(
const_cast<char*
>(str.data() + str.size())));
4556 std::transform(begin,end,begin,::toupper);
4571 reinterpret_cast<unsigned char*>(end));
4577 reinterpret_cast<unsigned char*
>(
const_cast<char*
>(str.data() + str.size())));
4582 std::transform(begin,end,begin,::tolower);
4597 reinterpret_cast<unsigned char*>(end));
4608 reinterpret_cast<unsigned char*
>(
const_cast<char*
>(str.data() + str.size())));
4626 const unsigned char* begin2,
const unsigned char* end2,
4634 static const std::size_t interleave_table_size = 256;
4635 static const unsigned short interleave_table[interleave_table_size] =
4637 0x0000, 0x0001, 0x0004, 0x0005, 0x0010, 0x0011, 0x0014, 0x0015,
4638 0x0040, 0x0041, 0x0044, 0x0045, 0x0050, 0x0051, 0x0054, 0x0055,
4639 0x0100, 0x0101, 0x0104, 0x0105, 0x0110, 0x0111, 0x0114, 0x0115,
4640 0x0140, 0x0141, 0x0144, 0x0145, 0x0150, 0x0151, 0x0154, 0x0155,
4641 0x0400, 0x0401, 0x0404, 0x0405, 0x0410, 0x0411, 0x0414, 0x0415,
4642 0x0440, 0x0441, 0x0444, 0x0445, 0x0450, 0x0451, 0x0454, 0x0455,
4643 0x0500, 0x0501, 0x0504, 0x0505, 0x0510, 0x0511, 0x0514, 0x0515,
4644 0x0540, 0x0541, 0x0544, 0x0545, 0x0550, 0x0551, 0x0554, 0x0555,
4645 0x1000, 0x1001, 0x1004, 0x1005, 0x1010, 0x1011, 0x1014, 0x1015,
4646 0x1040, 0x1041, 0x1044, 0x1045, 0x1050, 0x1051, 0x1054, 0x1055,
4647 0x1100, 0x1101, 0x1104, 0x1105, 0x1110, 0x1111, 0x1114, 0x1115,
4648 0x1140, 0x1141, 0x1144, 0x1145, 0x1150, 0x1151, 0x1154, 0x1155,
4649 0x1400, 0x1401, 0x1404, 0x1405, 0x1410, 0x1411, 0x1414, 0x1415,
4650 0x1440, 0x1441, 0x1444, 0x1445, 0x1450, 0x1451, 0x1454, 0x1455,
4651 0x1500, 0x1501, 0x1504, 0x1505, 0x1510, 0x1511, 0x1514, 0x1515,
4652 0x1540, 0x1541, 0x1544, 0x1545, 0x1550, 0x1551, 0x1554, 0x1555,
4653 0x4000, 0x4001, 0x4004, 0x4005, 0x4010, 0x4011, 0x4014, 0x4015,
4654 0x4040, 0x4041, 0x4044, 0x4045, 0x4050, 0x4051, 0x4054, 0x4055,
4655 0x4100, 0x4101, 0x4104, 0x4105, 0x4110, 0x4111, 0x4114, 0x4115,
4656 0x4140, 0x4141, 0x4144, 0x4145, 0x4150, 0x4151, 0x4154, 0x4155,
4657 0x4400, 0x4401, 0x4404, 0x4405, 0x4410, 0x4411, 0x4414, 0x4415,
4658 0x4440, 0x4441, 0x4444, 0x4445, 0x4450, 0x4451, 0x4454, 0x4455,
4659 0x4500, 0x4501, 0x4504, 0x4505, 0x4510, 0x4511, 0x4514, 0x4515,
4660 0x4540, 0x4541, 0x4544, 0x4545, 0x4550, 0x4551, 0x4554, 0x4555,
4661 0x5000, 0x5001, 0x5004, 0x5005, 0x5010, 0x5011, 0x5014, 0x5015,
4662 0x5040, 0x5041, 0x5044, 0x5045, 0x5050, 0x5051, 0x5054, 0x5055,
4663 0x5100, 0x5101, 0x5104, 0x5105, 0x5110, 0x5111, 0x5114, 0x5115,
4664 0x5140, 0x5141, 0x5144, 0x5145, 0x5150, 0x5151, 0x5154, 0x5155,
4665 0x5400, 0x5401, 0x5404, 0x5405, 0x5410, 0x5411, 0x5414, 0x5415,
4666 0x5440, 0x5441, 0x5444, 0x5445, 0x5450, 0x5451, 0x5454, 0x5455,
4667 0x5500, 0x5501, 0x5504, 0x5505, 0x5510, 0x5511, 0x5514, 0x5515,
4668 0x5540, 0x5541, 0x5544, 0x5545, 0x5550, 0x5551, 0x5554, 0x5555
4671 const unsigned char* itr1 = begin1;
4672 const unsigned char* itr2 = begin2;
4673 while (end1 != itr1)
4675 *(
reinterpret_cast<unsigned short*
>(out)) = (interleave_table[*(itr2++)] << 1);
4676 *(
reinterpret_cast<unsigned short*
>(out)) |= interleave_table[*(itr1++)];
4683 const char* begin2,
const char* end2,
4687 reinterpret_cast<const unsigned char*>(end1),
4688 reinterpret_cast<const unsigned char*>(begin2),
4689 reinterpret_cast<const unsigned char*>(end2),
4690 reinterpret_cast<unsigned char*>(out));
4697 if (str1.size() != str2.size())
4701 out.resize(str1.size());
4703 str2.data(),str2.data() + str2.size(),
4704 const_cast<char*
>(out.data()));
4707 template <std::
size_t n>
4712 template<>
struct interleave_ary<sizeof(unsigned long long int)> {
typedef unsigned long long int type; };
4714 template <std::
size_t n>
4718 const type diff =
static_cast<type
>(n - 1);
4719 for (type i = static_cast<type>(0); i < static_cast<type>(256); ++i)
4722 for (type j = static_cast<type>(0); j < static_cast<type>(8); ++j)
4724 table[i] |= (i & (1 << j)) << (j * diff);
4732 const unsigned char* begin1,
const unsigned char* end1,
4733 const unsigned char* begin2,
4736 const unsigned char* itr1 = begin1;
4737 const unsigned char* itr2 = begin2;
4748 const char* begin1,
const char* end1,
4753 reinterpret_cast<const unsigned char*>(begin1),
4754 reinterpret_cast<const unsigned char*>(end1),
4755 reinterpret_cast<const unsigned char*>(begin2),
4756 reinterpret_cast<unsigned char*>(out));
4764 if (str1.size() != str2.size())
return;
4765 out.resize(str1.size());
4767 str1.data(),str1.data() + str1.size(),
4769 const_cast<char*
>(out.data()));
4774 static const std::size_t high_bits_in_char[256] =
4776 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
4777 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
4778 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
4779 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4780 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
4781 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4782 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4783 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4784 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
4785 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4786 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4787 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4788 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
4789 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4790 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
4791 4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
4793 return high_bits_in_char[c];
4798 const unsigned char*
ptr =
reinterpret_cast<const unsigned char*
>(&s);
4804 const unsigned char*
ptr =
reinterpret_cast<const unsigned char*
>(&i);
4811 const unsigned char*
ptr =
reinterpret_cast<const unsigned char*
>(&ll);
4818 inline std::size_t
high_bit_count(
const unsigned char* begin,
const unsigned char* end)
4820 std::size_t count = 0;
4821 const unsigned char* itr = begin;
4831 return high_bit_count(reinterpret_cast<const unsigned char*>(begin),
4832 reinterpret_cast<const unsigned char*>(end));
4843 static const unsigned char bit_mask[] =
4854 return (0 != (ptr[(index >> 3)] & bit_mask[index & 7]));
4859 static const unsigned char bit_mask[] =
4870 ptr[(index >> 3)] |= bit_mask[index & 7];
4875 static const unsigned char bit_mask[] =
4886 ptr[(index >> 3)] &= bit_mask[index & 7];
4890 const unsigned char* begin2,
const unsigned char* end2)
4894 return std::numeric_limits<std::size_t>::max();
4898 const unsigned char* itr1 = begin1;
4899 const unsigned char* itr2 = begin2;
4901 while (end1 != itr1)
4903 distance +=
high_bit_count(static_cast<unsigned char>(((*itr1++) ^ (*itr2++)) & 0xFF));
4910 const char* begin2,
const char* end2)
4913 reinterpret_cast<const unsigned char*>(end1),
4914 reinterpret_cast<const unsigned char*>(begin2),
4915 reinterpret_cast<const unsigned char*>(end2));
4921 str2.data(), str2.data() + str2.size());
4924 template <
typename Iterator>
4926 const Iterator begin2,
const Iterator end2)
4930 return std::numeric_limits<std::size_t>::max();
4934 Iterator itr1 = begin1;
4935 Iterator itr2 = begin2;
4937 while (end1 != itr1)
4939 if ((*itr1) != (*itr2))
4949 str2.data(), str2.data() + str2.size());
4975 std::size_t max_column;
4983 inline range_t operator()(
const std::size_t& col,
const std::size_t&
row)
const
4985 if (row < row_index.size())
4988 if (col < (r.second - r.first + 1))
4989 return *(token_list.begin() + (r.first + col));
4991 return null_range();
4994 return null_range();
4997 inline bool remove_row(
const std::size_t& row)
4999 if (row >= row_index.size())
return false;
5001 std::size_t number_of_tokens = r.second - r.first + 1;
5002 token_list_t::iterator remove_begin = token_list.begin() + r.first;
5003 token_list_t::iterator remove_end = token_list.begin() + r.first + number_of_tokens;
5004 token_list.erase(remove_begin,remove_end);
5005 row_index.erase(row_index.begin() +
row);
5006 for (std::size_t i = row; i < row_index.size(); ++i)
5009 r.first -=
static_cast<unsigned int>(number_of_tokens);
5010 r.second -=
static_cast<unsigned int>(number_of_tokens);
5017 return (r.second - r.first + 1);
5020 inline std::size_t token_count(
const std::size_t& index)
const
5022 return token_count(row_index[index]);
5025 inline bool remove_row_range(
const std::size_t& r0,
const std::size_t& r1)
5029 else if (r0 >= row_index.size())
5031 else if (r1 >= row_index.size())
5033 std::size_t number_of_tokens = 0;
5034 for (std::size_t i = r0; i <= r1; ++i)
5037 number_of_tokens += token_count(r);
5040 token_list_t::iterator remove_begin = token_list.begin() + rr0.first;
5041 token_list_t::iterator remove_end = token_list.begin() + rr0.first + number_of_tokens;
5042 token_list.erase(remove_begin,remove_end);
5043 row_index.erase(row_index.begin() + r0,row_index.begin() + r0 + (r1 - r0 + 1));
5044 for (std::size_t i = r0; i < row_index.size(); ++i)
5047 r.first -=
static_cast<unsigned int>(number_of_tokens);
5048 r.second -=
static_cast<unsigned int>(number_of_tokens);
5065 std::size_t number_of_tokens = idx.token_count(
current_row);
5066 if (number_of_tokens >
column)
5075 remainder = (r.second - r.first) -
column;
5078 counter = std::numeric_limits<std::size_t>::max();
5083 token_list_t::iterator itr1 = idx.token_list.begin();
5084 token_list_t::iterator itr2 = idx.token_list.begin();
5085 token_list_t::iterator end = idx.token_list.end();
5092 while ((end != itr1) && (0 !=
counter))
5108 std::size_t remove_count = 0;
5109 idx.max_column = std::numeric_limits<std::size_t>::min();
5110 for (std::size_t i = 0; i < idx.row_index.size(); ++i)
5113 std::size_t token_count = (r.second - r.first + 1);
5114 r.first -=
static_cast<unsigned int>(remove_count);
5115 if (token_count >
column)
5119 r.second -=
static_cast<unsigned int>(remove_count);
5120 token_count = (r.second - r.first + 1);
5121 if (token_count > idx.max_column)
5122 idx.max_column = token_count;
5124 idx.token_list.resize(idx.token_list.size() - remove_count);
5128 inline bool remove_column(
const std::size_t& column)
5130 if (column >= max_column)
return false;
5131 remove_column_impl rc;
5137 inline static range_t null_range()
5139 static const range_t null_range_ =
range_t(reinterpret_cast<const unsigned char*>(0),
5140 reinterpret_cast<const unsigned char*>(0));
5146 template <
typename DelimiterPredicate = multiple_
char_delimiter_predicate>
5147 struct row_processor
5149 row_processor(store& idx,
5150 DelimiterPredicate& tp,
5153 row_start_index_(0),
5155 token_predicate_(tp),
5156 split_mode_(split_mode)
5158 idx_.max_column = std::numeric_limits<std::size_t>::min();
5165 row_start_index_ = idx_.token_list.size();
5166 std::size_t token_count =
split(token_predicate_,
5167 range.first,range.second,
5168 std::back_inserter(idx_.token_list),
5170 row_end_index_ = row_start_index_ + token_count - 1;
5171 idx_.row_index.push_back(
std::make_pair(row_start_index_,row_end_index_));
5172 if (token_count > idx_.max_column)
5173 idx_.max_column = token_count;
5176 row_processor<DelimiterPredicate> operator=(
const row_processor<DelimiterPredicate>&);
5179 std::size_t row_start_index_;
5180 std::size_t row_end_index_;
5181 DelimiterPredicate& token_predicate_;
5188 std::size_t upper_bound = std::numeric_limits<std::size_t>::max())
const
5190 if (upper_bound == std::numeric_limits<std::size_t>::max())
5192 upper_bound = dsv_index_.token_list.size();
5194 else if (upper_bound > dsv_index_.token_list.size())
5196 return row_range_t(std::numeric_limits<std::size_t>::max(),std::numeric_limits<std::size_t>::max());
5198 else if (lower_bound > upper_bound)
5200 return row_range_t(std::numeric_limits<std::size_t>::max(),std::numeric_limits<std::size_t>::max());
5219 const bool support_dq =
false)
5262 typedef std::pair<bool,row_type*> row_pair_type;
5267 : index_(std::numeric_limits<std::size_t>::max()),
5272 const store& dsv_index)
5274 size_ (dsv_index.token_count(index)),
5275 begin_(dsv_index.token_list.begin() + dsv_index.row_index[index].first)
5278 template <
typename T>
5282 return string_to_type_converter<T>(range.first,range.second);
5285 template <
typename T>
5288 return operator[]<
T>(
index);
5298 return range_t((*begin_).first,(*(begin_ + (size_ - 1))).second);
5303 return *(begin_ +
index);
5318 std::size_t result = 0;
5319 token_list_t::const_iterator itr = begin_;
5320 for (std::size_t i = 0; i < size_; ++i, ++itr)
5322 const range_t& range = (*itr);
5328 inline std::size_t
raw_length(
const std::size_t& column_index)
const
5330 const range_t& range = *(begin_ + column_index);
5337 result.reserve(
std::distance(begin_->first,(begin_ + (size_ - 1))->second));
5338 token_list_t::const_iterator itr = begin_;
5339 for (std::size_t i = 0; i < size_; ++i, ++itr)
5341 const range_t& range = (*itr);
5342 result.append(range.first,range.second);
5352 template <
typename T0,
typename T1,
typename T2,
typename T3,
5353 typename T4,
typename T5,
typename T6,
typename T7,
5354 typename T8,
typename T9>
5356 const std::size_t& col2,
const std::size_t& col3,
5357 const std::size_t& col4,
const std::size_t& col5,
5358 const std::size_t& col6,
const std::size_t& col7,
5359 const std::size_t& col8,
const std::size_t& col9,
5360 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
5361 T6& t6, T7& t7, T8& t8, T9& t9)
const
5363 if (!process(*(begin_ + col0),t0))
return false;
5364 if (!process(*(begin_ + col1),t1))
return false;
5365 if (!process(*(begin_ + col2),t2))
return false;
5366 if (!process(*(begin_ + col3),t3))
return false;
5367 if (!process(*(begin_ + col4),t4))
return false;
5368 if (!process(*(begin_ + col5),t5))
return false;
5369 if (!process(*(begin_ + col6),t6))
return false;
5370 if (!process(*(begin_ + col7),t7))
return false;
5371 if (!process(*(begin_ + col8),t8))
return false;
5372 if (!process(*(begin_ + col9),t9))
return false;
5376 template <
typename T0,
typename T1,
typename T2,
typename T3,
5377 typename T4,
typename T5,
typename T6,
typename T7,
5380 const std::size_t& col2,
const std::size_t& col3,
5381 const std::size_t& col4,
const std::size_t& col5,
5382 const std::size_t& col6,
const std::size_t& col7,
5383 const std::size_t& col8,
5384 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
5385 T6& t6, T7& t7, T8& t8)
const
5387 if (!process(*(begin_ + col0),t0))
return false;
5388 if (!process(*(begin_ + col1),t1))
return false;
5389 if (!process(*(begin_ + col2),t2))
return false;
5390 if (!process(*(begin_ + col3),t3))
return false;
5391 if (!process(*(begin_ + col4),t4))
return false;
5392 if (!process(*(begin_ + col5),t5))
return false;
5393 if (!process(*(begin_ + col6),t6))
return false;
5394 if (!process(*(begin_ + col7),t7))
return false;
5395 if (!process(*(begin_ + col8),t8))
return false;
5399 template <
typename T0,
typename T1,
typename T2,
typename T3,
5400 typename T4,
typename T5,
typename T6,
typename T7>
5402 const std::size_t& col2,
const std::size_t& col3,
5403 const std::size_t& col4,
const std::size_t& col5,
5404 const std::size_t& col6,
const std::size_t& col7,
5405 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
5406 T6& t6, T7& t7)
const
5408 if (!process(*(begin_ + col0),t0))
return false;
5409 if (!process(*(begin_ + col1),t1))
return false;
5410 if (!process(*(begin_ + col2),t2))
return false;
5411 if (!process(*(begin_ + col3),t3))
return false;
5412 if (!process(*(begin_ + col4),t4))
return false;
5413 if (!process(*(begin_ + col5),t5))
return false;
5414 if (!process(*(begin_ + col6),t6))
return false;
5415 if (!process(*(begin_ + col7),t7))
return false;
5419 template <
typename T0,
typename T1,
typename T2,
typename T3,
5420 typename T4,
typename T5,
typename T6>
5422 const std::size_t& col2,
const std::size_t& col3,
5423 const std::size_t& col4,
const std::size_t& col5,
5424 const std::size_t& col6,
5425 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
5428 if (!process(*(begin_ + col0),t0))
return false;
5429 if (!process(*(begin_ + col1),t1))
return false;
5430 if (!process(*(begin_ + col2),t2))
return false;
5431 if (!process(*(begin_ + col3),t3))
return false;
5432 if (!process(*(begin_ + col4),t4))
return false;
5433 if (!process(*(begin_ + col5),t5))
return false;
5434 if (!process(*(begin_ + col6),t6))
return false;
5438 template <
typename T0,
typename T1,
typename T2,
typename T3,
5439 typename T4,
typename T5>
5441 const std::size_t& col2,
const std::size_t& col3,
5442 const std::size_t& col4,
const std::size_t& col5,
5443 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
const
5445 if (!process(*(begin_ + col0),t0))
return false;
5446 if (!process(*(begin_ + col1),t1))
return false;
5447 if (!process(*(begin_ + col2),t2))
return false;
5448 if (!process(*(begin_ + col3),t3))
return false;
5449 if (!process(*(begin_ + col4),t4))
return false;
5450 if (!process(*(begin_ + col5),t5))
return false;
5454 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
5456 const std::size_t& col2,
const std::size_t& col3,
5457 const std::size_t& col4,
5458 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4)
const
5460 if (!process(*(begin_ + col0),t0))
return false;
5461 if (!process(*(begin_ + col1),t1))
return false;
5462 if (!process(*(begin_ + col2),t2))
return false;
5463 if (!process(*(begin_ + col3),t3))
return false;
5464 if (!process(*(begin_ + col4),t4))
return false;
5468 template <
typename T0,
typename T1,
typename T2,
typename T3>
5470 const std::size_t& col2,
const std::size_t& col3,
5471 T0& t0, T1& t1, T2& t2, T3& t3)
const
5473 if (!process(*(begin_ + col0),t0))
return false;
5474 if (!process(*(begin_ + col1),t1))
return false;
5475 if (!process(*(begin_ + col2),t2))
return false;
5476 if (!process(*(begin_ + col3),t3))
return false;
5480 template <
typename T0,
typename T1,
typename T2>
5482 const std::size_t& col2,
5483 T0& t0, T1& t1, T2& t2)
const
5485 if (!process(*(begin_ + col0),t0))
return false;
5486 if (!process(*(begin_ + col1),t1))
return false;
5487 if (!process(*(begin_ + col2),t2))
return false;
5491 template <
typename T0,
typename T1>
5493 T0& t0, T1& t1)
const
5495 if (!process(*(begin_ + col0),t0))
return false;
5496 if (!process(*(begin_ + col1),t1))
return false;
5500 template <
typename T>
5503 return process(*(begin_ + col),t);
5506 template <
typename T0,
typename T1,
typename T2,
typename T3,
5507 typename T4,
typename T5,
typename T6,
typename T7,
5508 typename T8,
typename T9 >
5509 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3,
5510 T4& t4, T5& t5, T6& t6, T7& t7,
5511 T8& t8, T9& t9)
const
5513 if (!process(*(begin_ + 0),t0))
return false;
5514 if (!process(*(begin_ + 1),t1))
return false;
5515 if (!process(*(begin_ + 2),t2))
return false;
5516 if (!process(*(begin_ + 3),t3))
return false;
5517 if (!process(*(begin_ + 4),t4))
return false;
5518 if (!process(*(begin_ + 5),t5))
return false;
5519 if (!process(*(begin_ + 6),t6))
return false;
5520 if (!process(*(begin_ + 7),t7))
return false;
5521 if (!process(*(begin_ + 8),t8))
return false;
5522 if (!process(*(begin_ + 9),t9))
return false;
5526 template <
typename T0,
typename T1,
typename T2,
typename T3,
5527 typename T4,
typename T5,
typename T6,
typename T7,
5529 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3,
5530 T4& t4, T5& t5, T6& t6, T7& t7,
5533 if (!process(*(begin_ + 0),t0))
return false;
5534 if (!process(*(begin_ + 1),t1))
return false;
5535 if (!process(*(begin_ + 2),t2))
return false;
5536 if (!process(*(begin_ + 3),t3))
return false;
5537 if (!process(*(begin_ + 4),t4))
return false;
5538 if (!process(*(begin_ + 5),t5))
return false;
5539 if (!process(*(begin_ + 6),t6))
return false;
5540 if (!process(*(begin_ + 7),t7))
return false;
5541 if (!process(*(begin_ + 8),t8))
return false;
5545 template <
typename T0,
typename T1,
typename T2,
typename T3,
5546 typename T4,
typename T5,
typename T6,
typename T7>
5547 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3,
5548 T4& t4, T5& t5, T6& t6, T7& t7)
const
5550 if (!process(*(begin_ + 0),t0))
return false;
5551 if (!process(*(begin_ + 1),t1))
return false;
5552 if (!process(*(begin_ + 2),t2))
return false;
5553 if (!process(*(begin_ + 3),t3))
return false;
5554 if (!process(*(begin_ + 4),t4))
return false;
5555 if (!process(*(begin_ + 5),t5))
return false;
5556 if (!process(*(begin_ + 6),t6))
return false;
5557 if (!process(*(begin_ + 7),t7))
return false;
5561 template <
typename T0,
typename T1,
typename T2,
typename T3,
5562 typename T4,
typename T5,
typename T6>
5563 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3,
5564 T4& t4, T5& t5, T6& t6)
const
5566 if (!process(*(begin_ + 0),t0))
return false;
5567 if (!process(*(begin_ + 1),t1))
return false;
5568 if (!process(*(begin_ + 2),t2))
return false;
5569 if (!process(*(begin_ + 3),t3))
return false;
5570 if (!process(*(begin_ + 4),t4))
return false;
5571 if (!process(*(begin_ + 5),t5))
return false;
5572 if (!process(*(begin_ + 6),t6))
return false;
5576 template <
typename T0,
typename T1,
typename T2,
typename T3,
5577 typename T4,
typename T5>
5578 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3,
5579 T4& t4, T5& t5)
const
5581 if (!process(*(begin_ + 0),t0))
return false;
5582 if (!process(*(begin_ + 1),t1))
return false;
5583 if (!process(*(begin_ + 2),t2))
return false;
5584 if (!process(*(begin_ + 3),t3))
return false;
5585 if (!process(*(begin_ + 4),t4))
return false;
5586 if (!process(*(begin_ + 5),t5))
return false;
5590 template <
typename T0,
typename T1,
5591 typename T2,
typename T3,
typename T4>
5592 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3, T4& t4)
const
5594 if (!process(*(begin_ + 0),t0))
return false;
5595 if (!process(*(begin_ + 1),t1))
return false;
5596 if (!process(*(begin_ + 2),t2))
return false;
5597 if (!process(*(begin_ + 3),t3))
return false;
5598 if (!process(*(begin_ + 4),t4))
return false;
5602 template <
typename T0,
typename T1,
5603 typename T2,
typename T3>
5604 inline bool parse(T0& t0, T1& t1, T2& t2, T3& t3)
const
5606 if (!process(*(begin_ + 0),t0))
return false;
5607 if (!process(*(begin_ + 1),t1))
return false;
5608 if (!process(*(begin_ + 2),t2))
return false;
5609 if (!process(*(begin_ + 3),t3))
return false;
5613 template <
typename T0,
typename T1,
typename T2>
5614 inline bool parse(T0& t0, T1& t1, T2& t2)
const
5616 if (!process(*(begin_ + 0),t0))
return false;
5617 if (!process(*(begin_ + 1),t1))
return false;
5618 if (!process(*(begin_ + 2),t2))
return false;
5622 template <
typename T0,
typename T1>
5625 if (!process(*(begin_ + 0),t0))
return false;
5626 if (!process(*(begin_ + 1),t1))
return false;
5630 template <
typename T0>
5633 return process(*begin_,t);
5636 template <
typename T,
typename OutputIterator>
5639 token_list_t::const_iterator itr = begin_;
5640 const token_list_t::const_iterator end = begin_ + size_;
5643 const range_t& range = (*itr);
5644 *(out++) = string_to_type_converter<T>(range.first,range.second);
5651 if ((range.first >
size()) || (range.second >
size()))
5653 else if (range.first > range.second)
5660 const std::size_t& upper_bound = std::numeric_limits<std::size_t>::max())
const
5662 if (std::numeric_limits<std::size_t>::max() != upper_bound)
5668 template <
typename T,
5670 template <
typename,
typename>
class Sequence>
5672 Sequence<T,Allocator>& sequence)
const
5676 token_list_t::const_iterator itr = (begin_ + range.first);
5677 token_list_t::const_iterator end = (begin_ + range.second);
5681 const range_t& range = (*itr);
5683 sequence.push_back(t);
5691 template <
typename T,
5692 typename Comparator,
5695 std::set<T,Comparator,Allocator>& set)
const
5699 token_list_t::const_iterator itr = (begin_ + range.first);
5700 token_list_t::const_iterator end = (begin_ + range.second);
5704 const range_t& range = (*itr);
5714 template <
typename T,
5715 typename Comparator,
5718 std::multiset<T,Comparator,Allocator>& multiset)
const
5722 token_list_t::const_iterator itr = (begin_ + range.first);
5723 token_list_t::const_iterator end = (begin_ + range.second);
5727 const range_t& range = (*itr);
5737 template <
typename T,
typename Container>
5739 std::queue<T,Container>& queue)
const
5743 token_list_t::const_iterator itr = (begin_ + range.first);
5744 token_list_t::const_iterator end = (begin_ + range.second);
5748 const range_t& range = (*itr);
5758 template <
typename T,
typename Container>
5760 std::stack<T,Container>& stack)
const
5764 token_list_t::const_iterator itr = (begin_ + range.first);
5765 token_list_t::const_iterator end = (begin_ + range.second);
5769 const range_t& range = (*itr);
5779 template <
typename T,
5781 typename Comparator>
5783 std::priority_queue<T,Container,Comparator>& priority_queue)
const
5787 token_list_t::const_iterator itr = (begin_ + range.first);
5788 token_list_t::const_iterator end = (begin_ + range.second);
5792 const range_t& range = (*itr);
5794 priority_queue.push(t);
5802 template <
typename T,
5804 template <
typename,
typename>
class Sequence>
5805 inline bool parse(Sequence<T,Allocator>& sequence)
const
5810 template <
typename T,
5811 typename Comparator,
5813 inline bool parse(std::set<T,Comparator,Allocator>& set)
const
5818 template <
typename T,
5819 typename Comparator,
5821 inline bool parse(std::multiset<T,Comparator,Allocator>& multiset)
const
5826 template <
typename T,
typename Container>
5827 inline bool parse(std::queue<T,Container>& queue)
const
5832 template <
typename T,
typename Container>
5833 inline bool parse(std::stack<T,Container>& stack)
const
5838 template <
typename T,
5840 typename Comparator>
5841 inline bool parse(std::priority_queue<T,Container,Comparator>& priority_queue)
const
5846 template <
typename T,
5848 template <
typename,
typename>
class Sequence>
5849 inline std::size_t
parse_n(
const std::size_t& n, Sequence<T,Allocator>& sequence)
const
5851 if (0 == n)
return 0;
5853 std::size_t count = 0;
5854 token_list_t::const_iterator itr = begin_;
5855 const token_list_t::const_iterator end = begin_ + size_;
5858 const range_t& range = (*itr);
5862 sequence.push_back(t);
5870 template <
typename T,
typename OutputIterator>
5874 token_list_t::const_iterator itr = begin_;
5875 const token_list_t::const_iterator end = begin_ + size_;
5878 const range_t& range = (*itr);
5887 template <
typename T,
5889 template <
typename,
typename>
class Sequence>
5892 parse_checked<T>(std::back_inserter(sequence));
5895 template <
typename T,
5896 typename Comparator,
5903 template <
typename T,
5904 typename Comparator,
5906 inline void parse_checked(std::multiset<T,Comparator,Allocator>& multiset)
const
5911 template <
typename T,
typename Container>
5917 template <
typename T,
typename Container>
5923 template <
typename T,
5925 typename Comparator>
5926 inline void parse_checked(std::priority_queue<T,Container,Comparator>& priority_queue)
const
5931 template <
typename Function>
5936 token_list_t::const_iterator itr = begin_ + range.first;
5937 token_list_t::const_iterator end = begin_ + range.second;
5938 std::size_t col_count = 0;
5941 const range_t& range = (*itr);
5949 template <
typename Function>
5957 template <
typename T>
5958 inline bool process(
const range_t& range,
T& t)
const
5967 token_list_t::const_iterator begin_;
5974 min_column_count_(0),
5975 max_column_count_(0),
5976 load_from_file_(false),
5982 : file_name_(file_name),
5985 min_column_count_(0),
5986 max_column_count_(0),
5988 load_from_file_(true),
5993 const std::size_t& input_buffer_size,
5996 buffer_(const_cast<unsigned char*>(input_buffer)),
5997 buffer_size_(input_buffer_size),
5998 min_column_count_(0),
5999 max_column_count_(0),
6001 load_from_file_(false),
6006 const std::size_t& input_buffer_size,
6009 buffer_(reinterpret_cast<unsigned char*>(const_cast<char*>(input_buffer))),
6010 buffer_size_(input_buffer_size),
6011 min_column_count_(0),
6012 max_column_count_(0),
6014 load_from_file_(false),
6019 const std::size_t& input_buffer_size,
6022 buffer_(reinterpret_cast<unsigned char*>(const_cast<char*>(input_buffer.data()))),
6023 buffer_size_(input_buffer_size),
6024 min_column_count_(0),
6025 max_column_count_(0),
6027 load_from_file_(false),
6034 : file_name_(file_name),
6037 min_column_count_(0),
6038 max_column_count_(0),
6043 load_from_file_(true),
6048 const std::size_t& input_buffer_size,
6052 buffer_(const_cast<unsigned char*>(input_buffer)),
6053 buffer_size_(input_buffer_size),
6054 min_column_count_(0),
6055 max_column_count_(0),
6060 load_from_file_(false),
6065 const std::size_t& input_buffer_size,
6069 buffer_(reinterpret_cast<unsigned char*>(const_cast<char*>(input_buffer))),
6070 buffer_size_(input_buffer_size),
6071 min_column_count_(0),
6072 max_column_count_(0),
6077 load_from_file_(false),
6082 const std::size_t& input_buffer_size,
6086 buffer_(reinterpret_cast<unsigned char*>(const_cast<char*>(input_buffer.data()))),
6087 buffer_size_(input_buffer_size),
6088 min_column_count_(0),
6089 max_column_count_(0),
6094 load_from_file_(false),
6100 if ((load_from_file_) && (0 != buffer_))
6119 return dsv_index_.row_index.size();
6124 return min_column_count_;
6129 return max_column_count_;
6132 inline range_t token(
const unsigned int& row,
const std::size_t& col)
const
6134 return dsv_index_(col,row);
6137 template <
typename T>
6138 inline T get(
const unsigned int&
row,
const std::size_t& col)
6141 return string_to_type_converter<T>(r.first,r.second);
6146 return row_type(row_index,dsv_index_);
6151 return row_range_t(0,static_cast<index_t>(dsv_index_.row_index.size()));
6154 template <
typename OutputIterator>
6156 const std::size_t& index,
6159 if (index > max_column_count_)
6161 else if (row_range_invalid(row_range))
6163 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6166 if (index < dsv_index_.token_count(row))
6168 dsv_index_.token_list.begin() + (row.first + index);
6169 process_token_checked(*(dsv_index_.token_list.begin() + (row.first + index)),out);
6175 template <
typename OutputIterator>
6182 template <
typename T,
6184 template <
typename,
typename>
class Sequence>
6186 Sequence<T,Allocator>& sequence)
const
6191 template <
typename T,
6192 typename Comparator,
6195 std::set<T,Comparator,Allocator>& set)
const
6200 template <
typename T,
6201 typename Comparator,
6204 std::multiset<T,Comparator,Allocator>& multiset)
const
6209 template <
typename OutputIterator>
6211 const std::size_t& index,
6215 if (index > max_column_count_)
6217 else if (row_range_invalid(row_range))
6219 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6222 if (index < dsv_index_.token_count(row))
6224 process_token(*(dsv_index_.token_list.begin() + (row.first + index)),out);
6230 template <
typename OutputIterator>
6237 template <
typename OutputIterator0,
typename OutputIterator1>
6239 const std::size_t& index0,
6240 const std::size_t& index1,
6241 OutputIterator0 out0,
6242 OutputIterator1 out1)
const
6244 if ((index0 > max_column_count_) ||
6245 (index1 > max_column_count_))
6247 else if (row_range_invalid(row_range))
6249 std::size_t max_index = std::max(index0,index1);
6250 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6253 if (max_index < dsv_index_.token_count(row))
6255 process_token(*(dsv_index_.token_list.begin() + (row.first + index0)),out0);
6256 process_token(*(dsv_index_.token_list.begin() + (row.first + index1)),out1);
6262 template <
typename OutputIterator0,
typename OutputIterator1,
typename OutputIterator2>
6264 const std::size_t& index0,
6265 const std::size_t& index1,
6266 const std::size_t& index2,
6267 OutputIterator0 out0,
6268 OutputIterator1 out1,
6269 OutputIterator2 out2)
const
6271 if ((index0 > max_column_count_) ||
6272 (index1 > max_column_count_) ||
6273 (index2 > max_column_count_))
6275 else if (row_range_invalid(row_range))
6277 std::size_t max_index = std::max(index0,std::max(index1,index2));
6278 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6281 if (max_index < dsv_index_.token_count(row))
6283 process_token(*(dsv_index_.token_list.begin() + (row.first + index0)),out0);
6284 process_token(*(dsv_index_.token_list.begin() + (row.first + index1)),out1);
6285 process_token(*(dsv_index_.token_list.begin() + (row.first + index2)),out2);
6291 template <
typename OutputIterator0,
typename OutputIterator1,
6292 typename OutputIterator2,
typename OutputIterator3>
6294 const std::size_t& index0,
6295 const std::size_t& index1,
6296 const std::size_t& index2,
6297 const std::size_t& index3,
6298 OutputIterator0 out0,
6299 OutputIterator1 out1,
6300 OutputIterator2 out2,
6301 OutputIterator3 out3)
const
6303 if ((index0 > max_column_count_) ||
6304 (index1 > max_column_count_) ||
6305 (index2 > max_column_count_) ||
6306 (index3 > max_column_count_))
6308 else if (row_range_invalid(row_range))
6310 std::size_t max_index = std::max(std::max(index0,index1),std::max(index2,index3));
6311 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6314 if (max_index < dsv_index_.token_count(row))
6316 process_token(*(dsv_index_.token_list.begin() + (row.first + index0)),out0);
6317 process_token(*(dsv_index_.token_list.begin() + (row.first + index1)),out1);
6318 process_token(*(dsv_index_.token_list.begin() + (row.first + index2)),out2);
6319 process_token(*(dsv_index_.token_list.begin() + (row.first + index3)),out3);
6325 template <
typename OutputIterator0,
typename OutputIterator1,
6326 typename OutputIterator2,
typename OutputIterator3,
6327 typename OutputIterator4>
6329 const std::size_t& index0,
6330 const std::size_t& index1,
6331 const std::size_t& index2,
6332 const std::size_t& index3,
6333 const std::size_t& index4,
6334 OutputIterator0 out0,
6335 OutputIterator1 out1,
6336 OutputIterator2 out2,
6337 OutputIterator3 out3,
6338 OutputIterator4 out4)
const
6340 if ((index0 > max_column_count_) ||
6341 (index1 > max_column_count_) ||
6342 (index2 > max_column_count_) ||
6343 (index3 > max_column_count_) ||
6344 (index4 > max_column_count_))
6346 else if (row_range_invalid(row_range))
6348 std::size_t max_index = std::max(index4,std::max(std::max(index0,index1),std::max(index2,index3)));
6349 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6352 if (max_index < dsv_index_.token_count(row))
6354 process_token(*(dsv_index_.token_list.begin() + (row.first + index0)),out0);
6355 process_token(*(dsv_index_.token_list.begin() + (row.first + index1)),out1);
6356 process_token(*(dsv_index_.token_list.begin() + (row.first + index2)),out2);
6357 process_token(*(dsv_index_.token_list.begin() + (row.first + index3)),out3);
6358 process_token(*(dsv_index_.token_list.begin() + (row.first + index4)),out4);
6366 if (index < dsv_index_.row_index.size())
6368 dsv_index_.remove_row(index);
6372 template <
typename Predicate>
6375 if (row_range_invalid(row_range))
6377 std::size_t removed_token_count = 0;
6378 std::deque<std::size_t> remove_token_list;
6379 std::deque<std::size_t> remove_row_list;
6380 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6383 std::size_t temp_r_first = r.first - removed_token_count;
6387 remove_row_list.push_back(i);
6388 for (std::size_t j = r.first; j <= r.second; ++j)
6390 remove_token_list.push_back(j);
6392 removed_token_count += row.
size();
6394 r.first =
static_cast<unsigned int>(temp_r_first);
6395 r.second -=
static_cast<unsigned int>(removed_token_count);
6397 for (std::size_t i = row_range.second; i < dsv_index_.row_index.size(); ++i)
6400 r.first -=
static_cast<unsigned int>(removed_token_count);
6401 r.second -=
static_cast<unsigned int>(removed_token_count);
6403 if (!remove_row_list.empty())
6407 if (!remove_token_list.empty())
6414 template <
typename Predicate>
6420 template <
typename Predicate>
6423 if (row_range_invalid(row_range))
6425 std::size_t removed_token_count = 0;
6426 std::deque<std::size_t> remove_token_list;
6427 std::deque<std::size_t> remove_row_list;
6428 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6431 std::size_t temp_r_first = r.first - removed_token_count;
6433 for (std::size_t j = 0; j < row.
size(); ++j)
6435 if (predicate(row.
token(j)))
6437 remove_token_list.push_back(r.first + j);
6438 ++removed_token_count;
6441 r.first =
static_cast<unsigned int>(temp_r_first);
6442 r.second -=
static_cast<unsigned int>(removed_token_count);
6443 if (0 == dsv_index_.token_count(r))
6445 remove_row_list.push_back(i);
6448 for (std::size_t i = row_range.second; i < dsv_index_.row_index.size(); ++i)
6451 r.first -=
static_cast<unsigned int>(removed_token_count);
6452 r.second -=
static_cast<unsigned int>(removed_token_count);
6454 if (!remove_row_list.empty())
6458 if (!remove_token_list.empty())
6462 if (!remove_token_list.empty())
6464 update_minmax_columns();
6466 return remove_token_list.size();
6480 const std::size_t& column_count)
6482 if (row_range_invalid(row_range))
6484 remove_row_if(insufficient_number_of_columns(column_count));
6485 min_column_count_ = column_count;
6486 max_column_count_ = column_count;
6498 if (row_range_invalid(row_range))
6500 remove_row_if(insufficient_number_of_minmax_columns(min_column_count,max_column_count));
6511 inline void clear(
const bool force_delete_buffer =
false)
6513 if (load_from_file_ || force_delete_buffer)
6518 min_column_count_ = 0;
6519 max_column_count_ = 0;
6524 template <
typename T>
6527 if (row >= dsv_index_.row_index.size())
6530 token_list_t::const_iterator itr = dsv_index_.token_list.begin() + r.first;
6531 token_list_t::const_iterator end = dsv_index_.token_list.begin() + r.second + 1;
6532 std::size_t process_count = 0;
6533 T current_value =
T();
6538 result += current_value;
6545 return process_count;
6548 template <
typename T>
6553 if (col > max_column_count_)
6555 else if (row_range_invalid(row_range))
6557 std::size_t process_count = 0;
6558 T current_value =
T();
6559 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6562 if (col < dsv_index_.token_count(r))
6564 const range_t& range = *(dsv_index_.token_list.begin() + r.first + col);
6566 result += current_value;
6572 return process_count;
6575 template <
typename T>
6581 template <
typename T,
typename Predicate>
6587 if (col > max_column_count_)
6589 else if (row_range_invalid(row_range))
6591 std::size_t process_count = 0;
6592 T current_value =
T();
6593 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6596 if (col < dsv_index_.token_count(r))
6604 result += current_value;
6613 return process_count;
6616 template <
typename T,
typename Predicate>
6628 if (row >= dsv_index_.row_index.size())
6631 token_list_t::const_iterator itr = dsv_index_.token_list.begin() + r.first;
6632 token_list_t::const_iterator end = dsv_index_.token_list.begin() + r.second + (row < (dsv_index_.row_index.size() - 1) ? 1 : 0);
6633 result.reserve(delimiter.size() * dsv_index_.token_count(r) +
std::distance(itr->first,end->second));
6634 bool appended =
false;
6637 if (!delimiter.empty() && appended)
6638 result.append(delimiter);
6640 if ((*itr).first != (*itr).second)
6642 result.append((*itr).first,(*itr).second);
6650 template <
typename Predicate>
6652 Predicate predicate,
6656 if (row >= dsv_index_.row_index.size())
6659 token_list_t::const_iterator itr = (dsv_index_.token_list.begin() + r.first);
6660 token_list_t::const_iterator end = dsv_index_.token_list.begin() + r.second + (row < (dsv_index_.row_index.size() - 1) ? 1 : 0);
6661 result.reserve(delimiter.size() * dsv_index_.token_count(r) +
std::distance(itr->first,end->second));
6662 bool appended =
false;
6665 if (!delimiter.empty() && appended)
6666 result.append(delimiter);
6668 if ((*itr).first != (*itr).second)
6670 if (predicate(*itr))
6672 result.append((*itr).first,(*itr).second);
6681 template <
typename Predicate>
6683 Predicate predicate,
6684 const char* delimiter,
6695 if (col > max_column_count_)
6697 else if (row_range_invalid(row_range))
6699 bool appended =
false;
6700 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6703 if (col < dsv_index_.token_count(r))
6707 if (!delimiter.empty() && appended)
6708 result.append(delimiter);
6710 if (range.first != range.second)
6712 result.append(range.first,range.second);
6727 template <
typename Predicate>
6730 Predicate predicate,
6734 if (col > max_column_count_)
6736 else if (row_range_invalid(row_range))
6738 bool appended =
false;
6739 const std::size_t pre_end_index = row_range.second - 1;
6740 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6743 if (col < dsv_index_.token_count(r))
6747 if (!delimiter.empty() && appended && (pre_end_index != i))
6748 result.append(delimiter);
6750 if (range.first != range.second)
6754 result.append(range.first,range.second);
6763 template <
typename Predicate>
6772 template <
typename TransitionPredicate,
typename Function>
6774 TransitionPredicate p,
6777 if (row_range_invalid(row_range))
6780 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6784 if (r.first != r.second)
6795 if (r.first != row_range.second)
6797 r.second = row_range.second;
6804 template <
typename TransitionPredicate,
typename Function>
6815 template <
typename Function>
6818 if (row_range_invalid(row_range))
6821 for (std::size_t i = row_range.first; i < row_range.second; ++i)
6829 template <
typename Function>
6838 file_name_ = file_name;
6839 if ((load_from_file_) && (0 != buffer_))
6845 min_column_count_ = 0;
6846 max_column_count_ = 0;
6848 load_from_file_ =
true;
6855 if ((load_from_file_) && (0 != buffer_))
6865 const std::size_t buffer_size,
6869 if ((load_from_file_) && (0 != buffer_))
6874 min_column_count_ = 0;
6875 max_column_count_ = 0;
6877 load_from_file_ =
false;
6879 buffer_size_ = buffer_size;
6886 if ((load_from_file_) && (0 != buffer_))
6900 struct is_empty_token
6902 inline bool operator()(
const range_t& r)
const
6904 return r.first == r.second;
6908 struct insufficient_number_of_columns
6910 insufficient_number_of_columns(
const std::size_t& noc)
6914 inline bool operator()(
const row_type& row)
const
6916 return (num_of_cols != row.size());
6919 std::size_t num_of_cols;
6922 struct insufficient_number_of_minmax_columns
6924 insufficient_number_of_minmax_columns(
const std::size_t& min_col,
const std::size_t& max_col)
6929 inline bool operator()(
const row_type& row)
const
6938 class double_quotes_predicate
6942 double_quotes_predicate(
const std::string& delimiters)
6943 : in_bracket_range_(false),
6947 inline bool operator()(
const unsigned char c)
const
6951 in_bracket_range_ = !in_bracket_range_;
6954 else if (in_bracket_range_)
6962 in_bracket_range_ =
false;
6967 mutable bool in_bracket_range_;
6973 if (load_from_file_ && !load_buffer_from_file())
6976 dsv_index_.token_list.clear();
6977 dsv_index_.row_index.clear();
6979 multiple_char_delimiter_predicate text_newline_predicate(options_.
row_delimiters);
6985 buffer_, buffer_ + buffer_size_,
6987 row_processor<multiple_char_delimiter_predicate>(dsv_index_,token_predicate,options_.
column_split_option)),
6994 buffer_, buffer_ + buffer_size_,
6996 row_processor<double_quotes_predicate>(dsv_index_,token_predicate_dblq,options_.
column_split_option)),
6999 update_minmax_columns();
7003 inline bool load_buffer_from_file()
7005 std::ifstream stream(file_name_.c_str(),std::ios::binary);
7008 stream.seekg (0,std::ios::end);
7009 buffer_size_ =
static_cast<std::size_t
>(stream.tellg());
7010 if (0 == buffer_size_)
7012 stream.seekg (0,std::ios::beg);
7013 buffer_ =
new unsigned char[buffer_size_];
7014 stream.read(reinterpret_cast<char*>(buffer_),static_cast<std::streamsize>(buffer_size_));
7019 template <
typename OutputIterator>
7022 typedef typename std::iterator_traits<OutputIterator>::value_type output_type;
7023 (*out) = string_to_type_converter<output_type>(range.first,range.second);
7027 template <
typename OutputIterator>
7030 typedef typename std::iterator_traits<OutputIterator>::value_type output_type;
7039 inline bool row_range_invalid(
const row_range_t& row_range)
const
7041 if (row_range.first > dsv_index_.row_index.size())
7043 else if (row_range.second > dsv_index_.row_index.size())
7045 else if (row_range.first > row_range.second)
7051 inline void update_minmax_columns()
7053 min_column_count_ = std::numeric_limits<std::size_t>::max();
7054 max_column_count_ = std::numeric_limits<std::size_t>::min();
7055 for (std::size_t i = 0; i < dsv_index_.row_index.size(); ++i)
7058 const std::size_t number_of_tokens = dsv_index_.token_count(r);
7059 if (number_of_tokens > max_column_count_)
7060 max_column_count_ = number_of_tokens;
7061 if (number_of_tokens < min_column_count_)
7062 min_column_count_ = number_of_tokens;
7070 unsigned char* buffer_;
7071 std::size_t buffer_size_;
7072 std::size_t min_column_count_;
7073 std::size_t max_column_count_;
7075 bool load_from_file_;
7079 template <
typename T>
7082 if (range.first == range.second)
return false;
7083 t = string_to_type_converter<T>(
std::string(range.first,range.second));
7091 template <
typename InputIterator>
7092 inline bool operator()(
const InputIterator begin,
const InputIterator end)
7102 template <
typename InputIterator>
7103 inline bool operator()(
const InputIterator begin,
const InputIterator end)
7109 template <
typename OutputIterator>
7118 template <
typename Iterator>
7119 inline void operator() (
const std::pair<Iterator,Iterator>& range)
7121 if (range.first != range.second)
7132 template <
typename OutputPredicate>
7138 OutputPredicate& predicate,
7139 bool allow_through_on_match =
true)
7140 : allow_through_on_match_(allow_through_on_match),
7141 match_pattern_(match_pattern),
7142 predicate_(predicate)
7145 template <
typename Iterator>
7146 inline void operator() (
const std::pair<Iterator,Iterator>& range)
const
7148 if (
match(match_pattern_.begin(),match_pattern_.end(),range.first,range.second,
'*',
'?') ^ allow_through_on_match_)
7156 if (
match(match_pattern_,s) ^ allow_through_on_match_)
7167 bool allow_through_on_match_;
7169 OutputPredicate& predicate_;
7172 template <
typename OutputPredicate>
7178 OutputPredicate predicate,
7179 bool case_insensitive,
7180 bool allow_through_on_match =
true)
7181 : case_insensitive_(case_insensitive),
7182 allow_through_on_match_(allow_through_on_match),
7185 predicate_(predicate)
7188 template <
typename Iterator>
7189 inline void operator() (
const std::pair<Iterator,Iterator>& range)
const
7191 for (
const std::string* itr = begin_; end_ != itr; ++itr)
7193 if ((case_insensitive_ &&
7194 (
imatch((*itr).data(),(*itr).data() + (*itr).size(),range.first,range.second))) ||
7195 (!case_insensitive_ && std::equal((*itr).begin(),(*itr).end(),range.first)))
7197 if (allow_through_on_match_)
7205 if (!allow_through_on_match_)
7214 for (
const std::string* itr = begin_; end_ != itr; ++itr)
7216 if ((case_insensitive_ &&
7217 (
imatch((*itr).begin(),(*itr).end(),s.begin(),s.end()))) ||
7218 (!case_insensitive_ && std::equal((*itr).begin(),(*itr).end(),s.begin())))
7220 if (allow_through_on_match_)
7228 if (!allow_through_on_match_)
7241 bool case_insensitive_;
7242 bool allow_through_on_match_;
7245 OutputPredicate predicate_;
7248 template <
typename Iterator,
typename MatchPredicate>
7250 const Iterator& end,
7251 const MatchPredicate& predicate)
7255 if (predicate(*itr))
7262 template <std::
size_t length>
7265 template <
typename Iterator>
7266 inline bool operator()(
const Iterator begin,
const Iterator end)
const
7271 template <
typename Iterator>
7272 inline bool operator()(
const std::pair<Iterator,Iterator>& range)
const
7277 template <
typename T,
7279 template <
typename,
typename>
class Sequence>
7280 inline bool operator()(
const Sequence<T,Allocator>& sequence)
const
7282 return length == sequence.size();
7285 template <
typename T,
7286 typename Comparator,
7288 inline bool operator()(
const std::set<T,Comparator,Allocator>& set)
const
7290 return length == set.size();
7293 template <
typename T,
7294 typename Comparator,
7296 inline bool operator()(
const std::multiset<T,Comparator,Allocator>& multiset)
const
7298 return length == multiset.size();
7303 return length == str.size();
7307 template <std::
size_t length>
7310 template <
typename Iterator>
7311 inline bool operator()(
const Iterator begin,
const Iterator end)
const
7313 return std::distance(begin,end) <
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(length);
7316 template <
typename Iterator>
7317 inline bool operator()(
const std::pair<Iterator,Iterator>& range)
const
7319 return std::distance(range.first,range.second) <
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(length);
7322 template <
typename T,
7324 template <
typename,
typename>
class Sequence>
7325 inline bool operator()(
const Sequence<T,Allocator>& sequence)
const
7327 return sequence.size() < length;
7330 template <
typename T,
7331 typename Comparator,
7333 inline bool operator()(
const std::set<T,Comparator,Allocator>& set)
const
7335 return set.size() < length;
7338 template <
typename T,
7339 typename Comparator,
7341 inline bool operator()(
const std::multiset<T,Comparator,Allocator>& multiset)
const
7343 return multiset.size() < length;
7348 return str.size() < length;
7352 template <std::
size_t length>
7355 template <
typename Iterator>
7356 inline bool operator()(
const Iterator begin,
const Iterator end)
const
7358 return std::distance(begin,end) >
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(length);
7361 template <
typename Iterator>
7362 inline bool operator()(
const std::pair<Iterator,Iterator>& range)
const
7364 return std::distance(range.first,range.second) >
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(length);
7367 template <
typename T,
7369 template <
typename,
typename>
class Sequence>
7370 inline bool operator()(
const Sequence<T,Allocator>& sequence)
const
7372 return sequence.size() > length;
7375 template <
typename T,
7376 typename Comparator,
7378 inline bool operator()(
const std::set<T,Comparator,Allocator>& set)
const
7380 return set.size() > length;
7383 template <
typename T,
7384 typename Comparator,
7386 inline bool operator()(
const std::multiset<T,Comparator,Allocator>& multiset)
const
7388 return multiset.size() > length;
7393 return str.size() > length;
7399 template <
typename Iterator>
7400 inline bool operator()(
const Iterator begin,
const Iterator end)
const
7405 template <
typename Iterator>
7406 inline bool operator()(
const std::pair<Iterator,Iterator>& range)
const
7411 template <
typename T,
7413 template <
typename,
typename>
class Sequence>
7414 inline bool operator()(
const Sequence<T,Allocator>& sequence)
const
7416 return 0 == (sequence.size() % 2);
7419 template <
typename T,
7420 typename Comparator,
7422 inline bool operator()(
const std::set<T,Comparator,Allocator>& set)
const
7424 return 0 == (set.size() % 2);
7427 template <
typename T,
7428 typename Comparator,
7430 inline bool operator()(
const std::multiset<T,Comparator,Allocator>& multiset)
const
7432 return 0 == (multiset.size() % 2);
7437 return 0 == (str.size() % 2);
7443 template <
typename Iterator>
7444 inline bool operator()(
const Iterator begin,
const Iterator end)
const
7449 template <
typename Iterator>
7450 inline bool operator()(
const std::pair<Iterator,Iterator>& range)
const
7455 template <
typename T,
7457 template <
typename,
typename>
class Sequence>
7458 inline bool operator()(
const Sequence<T,Allocator>& sequence)
const
7460 return 0 != (sequence.size() % 2);
7463 template <
typename T,
7464 typename Comparator,
7466 inline bool operator()(
const std::set<T,Comparator,Allocator>& set)
const
7468 return 0 != (set.size() % 2);
7471 template <
typename T,
7472 typename Comparator,
7474 inline bool operator()(
const std::multiset<T,Comparator,Allocator>& multiset)
const
7476 return 0 != (multiset.size() % 2);
7481 return 0 != (str.size() % 2);
7485 template <
typename InputIterator,
7486 typename T1,
typename T2,
typename T3,
typename T4,
7487 typename T5,
typename T6,
typename T7,
typename T8,
7488 typename T9,
typename T10,
typename T11,
typename T12>
7489 inline bool parse(
const InputIterator begin,
7490 const InputIterator end,
7492 T1& t1, T2& t2, T3& t3, T4& t4,
7493 T5& t5, T6& t6, T7& t7, T8& t8,
7494 T9& t9, T10& t10, T11& t11, T12& t12)
7497 static const std::size_t token_count = 12;
7498 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7499 typedef iterator_type* iterator_type_ptr;
7500 iterator_type token_list[token_count];
7501 const std::size_t parsed_token_count =
split_n(delimiters,
7506 if (token_count > parsed_token_count)
7508 iterator_type_ptr itr = token_list;
7524 template <
typename InputIterator,
7525 typename T1,
typename T2,
typename T3,
typename T4,
7526 typename T5,
typename T6,
typename T7,
typename T8,
7527 typename T9,
typename T10,
typename T11>
7528 inline bool parse(
const InputIterator begin,
7529 const InputIterator end,
7531 T1& t1, T2& t2, T3& t3, T4& t4,
7532 T5& t5, T6& t6, T7& t7, T8& t8,
7533 T9& t9, T10& t10, T11& t11)
7536 static const std::size_t token_count = 11;
7537 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7538 typedef iterator_type* iterator_type_ptr;
7539 iterator_type token_list[token_count];
7540 const std::size_t parsed_token_count =
split_n(delimiters,
7545 if (token_count > parsed_token_count)
7547 iterator_type_ptr itr = token_list;
7562 template <
typename InputIterator,
7563 typename T1,
typename T2,
typename T3,
typename T4,
7564 typename T5,
typename T6,
typename T7,
typename T8,
7565 typename T9,
typename T10>
7566 inline bool parse(
const InputIterator begin,
7567 const InputIterator end,
7569 T1& t1, T2& t2, T3& t3, T4& t4,
7570 T5& t5, T6& t6, T7& t7, T8& t8,
7574 static const std::size_t token_count = 10;
7575 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7576 typedef iterator_type* iterator_type_ptr;
7577 iterator_type token_list[token_count];
7578 const std::size_t parsed_token_count =
split_n(delimiters,
7583 if (token_count > parsed_token_count)
7585 iterator_type_ptr itr = token_list;
7599 template <
typename InputIterator,
7600 typename T1,
typename T2,
typename T3,
typename T4,
7601 typename T5,
typename T6,
typename T7,
typename T8,
7603 inline bool parse(
const InputIterator begin,
7604 const InputIterator end,
7606 T1& t1, T2& t2, T3& t3, T4& t4,
7607 T5& t5, T6& t6, T7& t7, T8& t8,
7611 static const std::size_t token_count = 9;
7612 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7613 typedef iterator_type* iterator_type_ptr;
7614 iterator_type token_list[token_count];
7615 const std::size_t parsed_token_count =
split_n(delimiters,
7620 if (token_count > parsed_token_count)
7622 iterator_type_ptr itr = token_list;
7635 template <
typename InputIterator,
7636 typename T1,
typename T2,
typename T3,
typename T4,
7637 typename T5,
typename T6,
typename T7,
typename T8>
7638 inline bool parse(
const InputIterator begin,
7639 const InputIterator end,
7641 T1& t1, T2& t2, T3& t3, T4& t4,
7642 T5& t5, T6& t6, T7& t7, T8& t8)
7645 static const std::size_t token_count = 8;
7646 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7647 typedef iterator_type* iterator_type_ptr;
7648 iterator_type token_list[token_count];
7649 const std::size_t parsed_token_count =
split_n(delimiters,
7654 if (token_count > parsed_token_count)
7656 iterator_type_ptr itr = token_list;
7668 template <
typename InputIterator,
7669 typename T1,
typename T2,
typename T3,
typename T4,
7670 typename T5,
typename T6,
typename T7>
7671 inline bool parse(
const InputIterator begin,
7672 const InputIterator end,
7674 T1& t1, T2& t2, T3& t3, T4& t4,
7675 T5& t5, T6& t6, T7& t7)
7678 static const std::size_t token_count = 7;
7679 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7680 typedef iterator_type* iterator_type_ptr;
7681 iterator_type token_list[token_count];
7682 const std::size_t parsed_token_count =
split_n(delimiters,
7687 if (token_count > parsed_token_count)
7689 iterator_type_ptr itr = token_list;
7700 template <
typename InputIterator,
7701 typename T1,
typename T2,
typename T3,
typename T4,
7702 typename T5,
typename T6>
7703 inline bool parse(
const InputIterator begin,
7704 const InputIterator end,
7706 T1& t1, T2& t2, T3& t3, T4& t4,
7710 static const std::size_t token_count = 6;
7711 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7712 typedef iterator_type* iterator_type_ptr;
7713 iterator_type token_list[token_count];
7714 const std::size_t parsed_token_count =
split_n(delimiters,
7719 if (token_count > parsed_token_count)
7721 iterator_type_ptr itr = token_list;
7731 template <
typename InputIterator,
7732 typename T1,
typename T2,
typename T3,
typename T4,
7734 inline bool parse(
const InputIterator begin,
7735 const InputIterator end,
7737 T1& t1, T2& t2, T3& t3, T4& t4,
7741 static const std::size_t token_count = 5;
7742 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7743 typedef iterator_type* iterator_type_ptr;
7744 iterator_type token_list[token_count];
7745 const std::size_t parsed_token_count =
split_n(delimiters,
7750 if (token_count > parsed_token_count)
7752 iterator_type_ptr itr = token_list;
7761 template <
typename InputIterator,
7762 typename T1,
typename T2,
typename T3,
typename T4>
7763 inline bool parse(
const InputIterator begin,
7764 const InputIterator end,
7766 T1& t1, T2& t2, T3& t3, T4& t4)
7769 static const std::size_t token_count = 4;
7770 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7771 typedef iterator_type* iterator_type_ptr;
7772 iterator_type token_list[token_count];
7773 const std::size_t parsed_token_count =
split_n(delimiters,
7778 if (token_count > parsed_token_count)
7780 iterator_type_ptr itr = token_list;
7788 template <
typename InputIterator,
7789 typename T1,
typename T2,
typename T3>
7790 inline bool parse(
const InputIterator begin,
7791 const InputIterator end,
7793 T1& t1, T2& t2, T3& t3)
7796 static const std::size_t token_count = 3;
7797 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7798 typedef iterator_type* iterator_type_ptr;
7799 iterator_type token_list[token_count];
7800 const std::size_t parsed_token_count =
split_n(delimiters,
7805 if (token_count > parsed_token_count)
7807 iterator_type_ptr itr = token_list;
7814 template <
typename InputIterator,
typename T1,
typename T2>
7815 inline bool parse(
const InputIterator begin,
7816 const InputIterator end,
7821 static const std::size_t token_count = 2;
7822 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7823 typedef iterator_type* iterator_type_ptr;
7824 iterator_type token_list[token_count];
7825 const std::size_t parsed_token_count =
split_n(delimiters,
7830 if (token_count > parsed_token_count)
7832 iterator_type_ptr itr = token_list;
7838 template <
typename InputIterator,
typename T>
7839 inline bool parse(
const InputIterator begin,
7840 const InputIterator end,
7845 static const std::size_t token_count = 1;
7846 typedef std::pair<InputIterator,InputIterator>
iterator_type;
7847 typedef iterator_type* iterator_type_ptr;
7848 iterator_type token_list[token_count];
7849 const std::size_t parsed_token_count =
split_n(delimiters,
7854 if (token_count > parsed_token_count)
7856 iterator_type_ptr itr = token_list;
7860 template <
typename InputIterator,
7863 template <
typename,
typename>
class Sequence>
7864 inline std::size_t
parse(
const InputIterator begin,
7865 const InputIterator end,
7867 Sequence<T,Allocator>& sequence,
7871 if (1 == delimiters.size())
7883 template <
typename InputIterator,
7885 typename Comparator,
7887 inline std::size_t
parse(
const InputIterator begin,
7888 const InputIterator end,
7890 std::set<T,Comparator,Allocator>& set,
7894 if (1 == delimiters.size())
7906 template <
typename InputIterator,
7908 typename Comparator,
7910 inline std::size_t
parse(
const InputIterator begin,
7911 const InputIterator end,
7913 std::multiset<T,Comparator,Allocator>& multiset,
7917 if (1 == delimiters.size())
7929 template <
typename InputIterator,
7932 inline std::size_t
parse(
const InputIterator begin,
7933 const InputIterator end,
7935 std::queue<T,Container>& queue,
7939 if (1 == delimiters.size())
7951 template <
typename InputIterator,
7954 inline std::size_t
parse(
const InputIterator begin,
7955 const InputIterator end,
7957 std::stack<T,Container>& stack,
7961 if (1 == delimiters.size())
7973 template <
typename InputIterator,
7976 typename Comparator>
7977 inline std::size_t
parse(
const InputIterator begin,
7978 const InputIterator end,
7980 std::priority_queue<T,Container,Comparator>& priority_queue,
7984 if (1 == delimiters.size())
7996 template <
typename InputIterator,
7999 template <
typename,
typename>
class Sequence>
8000 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8002 Sequence<T,Allocator>& sequence,
8006 if (1 == delimiters.size())
8008 range.first,range.second,
8013 range.first,range.second,
8018 template <
typename InputIterator,
8020 typename Comparator,
8022 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8024 std::set<T,Comparator,Allocator>& set,
8028 if (1 == delimiters.size())
8030 range.first,range.second,
8035 range.first,range.second,
8040 template <
typename InputIterator,
8042 typename Comparator,
8044 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8046 std::multiset<T,Comparator,Allocator>& multiset,
8050 if (1 == delimiters.size())
8052 range.first,range.second,
8057 range.first,range.second,
8062 template <
typename InputIterator,
8065 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8067 std::queue<T,Container>& queue,
8071 if (1 == delimiters.size())
8073 range.first,range.second,
8078 range.first,range.second,
8083 template <
typename InputIterator,
8086 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8088 std::stack<T,Container>& stack,
8092 if (1 == delimiters.size())
8094 range.first,range.second,
8099 range.first,range.second,
8104 template <
typename InputIterator,
8107 typename Comparator>
8108 inline std::size_t
parse(
const std::pair<InputIterator,InputIterator>& range,
8110 std::priority_queue<T,Container,Comparator>& priority_queue,
8114 if (1 == delimiters.size())
8116 range.first,range.second,
8121 range.first,range.second,
8132 class container_adder_base
8136 typedef const char* itr_type;
8138 virtual ~container_adder_base(){}
8140 template <
typename InputIterator>
8141 inline bool add(
const InputIterator begin,
const InputIterator end)
const
8143 return add_impl(begin,end);
8146 template <
typename InputIterator>
8147 inline bool add(
const std::pair<InputIterator,InputIterator>& range)
const
8149 return add(range.first,range.second);
8154 virtual bool add_impl(
const itr_type begin,
const itr_type end)
const = 0;
8158 template <
typename T,
8160 template <
typename,
typename>
class Sequence>
8161 class sequence_adder_impl :
public container_adder_base
8165 typedef Sequence<T,Allocator> sequence_t;
8167 sequence_adder_impl(sequence_t& seq)
8173 bool add_impl(
const itr_type begin,
const itr_type end)
const
8177 sequence_.push_back(t);
8183 sequence_adder_impl operator=(
const sequence_adder_impl&);
8185 sequence_t& sequence_;
8188 template <
typename T,
8189 typename Comparator,
8191 template <
typename,
typename,
typename>
class Set>
8192 class set_adder_impl :
public container_adder_base
8196 set_adder_impl(Set<T,Comparator,Allocator>& set)
8200 bool add_impl(
const itr_type begin,
const itr_type end)
const
8210 set_adder_impl operator=(
const set_adder_impl&);
8212 Set<T,Comparator,Allocator>& set_;
8215 template <
typename T,
8217 typename Comparator>
8218 class pq_adder_impl :
public container_adder_base
8222 pq_adder_impl(std::priority_queue<T,Container,Comparator>& pq)
8226 bool add_impl(
const itr_type begin,
const itr_type end)
const
8236 pq_adder_impl operator=(
const pq_adder_impl&);
8238 std::priority_queue<T,Container,Comparator>& pq_;
8241 template <
typename T,
8243 template <
typename,
typename>
class SContainer>
8244 class stack_queue_adder_impl :
public container_adder_base
8248 stack_queue_adder_impl(SContainer<T,Container>& container)
8249 : container_(container)
8252 bool add_impl(
const itr_type begin,
const itr_type end)
const
8262 stack_queue_adder_impl operator=(
const stack_queue_adder_impl&);
8264 SContainer<T,Container>& container_;
8269 template <
typename T,
typename Allocator>
8271 : container_adder_base_(new(buffer)sequence_adder_impl<
T,Allocator,std::vector>(vec))
8274 template <
typename T,
typename Allocator>
8276 : container_adder_base_(new(buffer)sequence_adder_impl<
T,Allocator,std::deque>(deq))
8279 template <
typename T,
typename Allocator>
8281 : container_adder_base_(new(buffer)sequence_adder_impl<
T,Allocator,std::list>(list))
8284 template <
typename T,
typename Comparator,
typename Allocator>
8286 : container_adder_base_(new(buffer)set_adder_impl<
T,Comparator,Allocator,std::set>(set))
8289 template <
typename T,
typename Comparator,
typename Allocator>
8291 : container_adder_base_(new(buffer)set_adder_impl<
T,Comparator,Allocator,std::multiset>(multiset))
8294 template <
typename T,
typename Container,
typename Comparator>
8296 : container_adder_base_(new(buffer)pq_adder_impl<
T,Container,Comparator>(pq))
8299 template <
typename T,
typename Container>
8301 : container_adder_base_(new(buffer)stack_queue_adder_impl<
T,Container,std::queue>(queue))
8304 template <
typename T,
typename Container>
8306 : container_adder_base_(new(buffer)stack_queue_adder_impl<
T,Container,std::stack>(stack))
8309 template <
typename InputIterator>
8310 inline bool add(InputIterator begin, InputIterator end)
const
8312 return container_adder_base_->add(begin,end);
8315 template <
typename InputIterator>
8316 inline bool add(std::pair<InputIterator,InputIterator>& range)
const
8318 return add(range.first,range.second);
8321 template <
typename InputIterator>
8322 inline bool operator()(
const InputIterator begin,
const InputIterator end)
8324 InputIterator itr = begin;
8327 if (!
add(*itr))
return false;
8335 mutable container_adder_base* container_adder_base_;
8336 unsigned char buffer[64];
8339 template <
typename T,
typename is_stl_container_result>
8342 template <
typename T>
8347 template <
typename InputIterator,
8348 typename T1,
typename T2,
typename T3,
8349 typename T4,
typename T5,
typename T6,
8350 typename T7,
typename T8,
typename T9,
8351 typename T10,
typename T11>
8352 inline bool parse(
const InputIterator begin,
const InputIterator end,
8354 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7,
8355 T8& t8, T9& t9, T10& t10, T11& t11,
8359 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8360 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8361 std::deque<iterator_type> token_list;
8362 if (1 == delimiters.size())
8365 std::back_inserter(token_list),
8370 std::back_inserter(token_list),
8372 if (token_list.size() < 12)
return false;
8373 iterator_type_ptr itr = token_list.begin();
8385 return ca(itr,token_list.end());
8388 template <
typename InputIterator,
8389 typename T1,
typename T2,
typename T3,
8390 typename T4,
typename T5,
typename T6,
8391 typename T7,
typename T8,
typename T9,
8393 inline bool parse(
const InputIterator begin,
const InputIterator end,
8395 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9, T10& t10,
8399 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8400 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8401 std::deque<iterator_type> token_list;
8402 if (1 == delimiters.size())
8405 std::back_inserter(token_list),
8410 std::back_inserter(token_list),
8412 if (token_list.size() < 11)
return false;
8413 iterator_type_ptr itr = token_list.begin();
8424 return ca(itr,token_list.end());
8427 template <
typename InputIterator,
8428 typename T1,
typename T2,
typename T3,
8429 typename T4,
typename T5,
typename T6,
8430 typename T7,
typename T8,
typename T9>
8431 inline bool parse(
const InputIterator begin,
const InputIterator end,
8433 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8, T9& t9,
8437 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8438 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8439 std::deque<iterator_type> token_list;
8440 if (1 == delimiters.size())
8443 std::back_inserter(token_list),
8448 std::back_inserter(token_list),
8450 if (token_list.size() < 10)
return false;
8451 iterator_type_ptr itr = token_list.begin();
8461 return ca(itr,token_list.end());
8464 template <
typename InputIterator,
8465 typename T1,
typename T2,
typename T3,
8466 typename T4,
typename T5,
typename T6,
8467 typename T7,
typename T8>
8468 inline bool parse(
const InputIterator begin,
const InputIterator end,
8470 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7, T8& t8,
8474 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8475 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8476 std::deque<iterator_type> token_list;
8477 if (1 == delimiters.size())
8480 std::back_inserter(token_list),
8485 std::back_inserter(token_list),
8487 if (token_list.size() < 9)
return false;
8488 iterator_type_ptr itr = token_list.begin();
8497 return ca(itr,token_list.end());
8500 template <
typename InputIterator,
8501 typename T1,
typename T2,
typename T3,
8502 typename T4,
typename T5,
typename T6,
typename T7>
8503 inline bool parse(
const InputIterator begin,
const InputIterator end,
8505 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7,
8509 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8510 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8511 std::deque<iterator_type> token_list;
8512 if (1 == delimiters.size())
8515 std::back_inserter(token_list),
8520 std::back_inserter(token_list),
8522 if (token_list.size() < 8)
return false;
8523 iterator_type_ptr itr = token_list.begin();
8531 return ca(itr,token_list.end());
8534 template <
typename InputIterator,
8535 typename T1,
typename T2,
typename T3,
8536 typename T4,
typename T5,
typename T6>
8537 inline bool parse(
const InputIterator begin,
const InputIterator end,
8539 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
8543 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8544 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8545 std::deque<iterator_type> token_list;
8546 if (1 == delimiters.size())
8549 std::back_inserter(token_list),
8554 std::back_inserter(token_list),
8556 if (token_list.size() < 7)
return false;
8557 iterator_type_ptr itr = token_list.begin();
8564 return ca(itr,token_list.end());
8567 template <
typename InputIterator,
8568 typename T1,
typename T2,
typename T3,
8569 typename T4,
typename T5>
8570 inline bool parse(
const InputIterator begin,
const InputIterator end,
8572 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
8576 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8577 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8578 std::deque<iterator_type> token_list;
8579 if (1 == delimiters.size())
8582 std::back_inserter(token_list),
8587 std::back_inserter(token_list),
8589 if (token_list.size() < 6)
return false;
8590 iterator_type_ptr itr = token_list.begin();
8596 return ca(itr,token_list.end());
8599 template <
typename InputIterator,
8600 typename T1,
typename T2,
typename T3,
typename T4>
8601 inline bool parse(
const InputIterator begin,
const InputIterator end,
8603 T1& t1, T2& t2, T3& t3, T4& t4,
8607 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8608 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8609 std::deque<iterator_type> token_list;
8610 if (1 == delimiters.size())
8613 std::back_inserter(token_list),
8618 std::back_inserter(token_list),
8620 if (token_list.size() < 5)
return false;
8621 iterator_type_ptr itr = token_list.begin();
8626 return ca(itr,token_list.end());
8629 template <
typename InputIterator,
8630 typename T1,
typename T2,
typename T3>
8631 inline bool parse(
const InputIterator begin,
const InputIterator end,
8633 T1& t1, T2& t2, T3& t3,
8637 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8638 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8639 std::deque<iterator_type> token_list;
8640 if (1 == delimiters.size())
8643 std::back_inserter(token_list),
8648 std::back_inserter(token_list),
8650 if (token_list.size() < 4)
return false;
8651 iterator_type_ptr itr = token_list.begin();
8655 return ca(itr,token_list.end());
8658 template <
typename InputIterator,
8659 typename T1,
typename T2>
8660 inline bool parse(
const InputIterator begin,
const InputIterator end,
8666 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8667 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8668 std::deque<iterator_type> token_list;
8669 if (1 == delimiters.size())
8672 std::back_inserter(token_list),
8677 std::back_inserter(token_list),
8679 if (token_list.size() < 3)
return false;
8680 iterator_type_ptr itr = token_list.begin();
8683 return ca(itr,token_list.end());
8686 template <
typename InputIterator,
typename T1>
8687 inline bool parse(
const InputIterator begin,
const InputIterator end,
8693 typedef std::pair<InputIterator,InputIterator>
iterator_type;
8694 typedef typename std::deque<iterator_type>::iterator iterator_type_ptr;
8695 std::deque<iterator_type> token_list;
8696 if (1 == delimiters.size())
8699 std::back_inserter(token_list),
8704 std::back_inserter(token_list),
8706 if (token_list.size() < 2)
return false;
8707 iterator_type_ptr itr = token_list.begin();
8709 return ca(itr,token_list.end());
8712 template <
typename InputIterator,
8715 template <
typename,
typename>
class Sequence>
8716 inline std::size_t
parse_n(
const InputIterator begin,
8717 const InputIterator end,
8719 const std::size_t& n,
8720 Sequence<T,Allocator>& sequence,
8724 const std::size_t original_size = sequence.size();
8725 if (1 == delimiters.size())
8737 return sequence.size() - original_size;
8740 template <
typename InputIterator,
8742 typename Comparator,
8744 inline std::size_t
parse_n(
const InputIterator begin,
8745 const InputIterator end,
8747 const std::size_t& n,
8748 std::set<T,Comparator,Allocator>& set,
8752 const std::size_t original_size = set.size();
8753 if (1 == delimiters.size())
8765 return set.size() - original_size;
8768 template <
typename InputIterator,
8770 typename Comparator,
8772 inline std::size_t
parse_n(
const InputIterator begin,
8773 const InputIterator end,
8775 const std::size_t& n,
8776 std::multiset<T,Comparator,Allocator>& multiset,
8780 const std::size_t original_size = multiset.size();
8781 if (1 == delimiters.size())
8793 return multiset.size() - original_size;
8796 template <
typename InputIterator,
8799 inline std::size_t
parse_n(
const InputIterator begin,
8800 const InputIterator end,
8802 const std::size_t& n,
8803 std::queue<T,Container>& queue,
8807 const std::size_t original_size = queue.size();
8808 if (1 == delimiters.size())
8820 return queue.size() - original_size;
8823 template <
typename InputIterator,
8826 inline std::size_t
parse_n(
const InputIterator begin,
8827 const InputIterator end,
8829 const std::size_t& n,
8830 std::stack<T,Container>& stack,
8834 const std::size_t original_size = stack.size();
8835 if (1 == delimiters.size())
8847 return stack.size() - original_size;
8850 template <
typename InputIterator,
8853 typename Comparator>
8854 inline std::size_t
parse_n(
const InputIterator begin,
8855 const InputIterator end,
8857 const std::size_t& n,
8858 std::priority_queue<T,Container,Comparator>& priority_queue,
8862 const std::size_t original_size = priority_queue.size();
8863 if (1 == delimiters.size())
8875 return priority_queue.size() - original_size;
8878 template <
typename InputIterator,
typename T>
8879 inline std::size_t
parse_n(
const InputIterator begin,
8880 const InputIterator end,
8882 const std::size_t& n,
8887 std::size_t insert_count = 0;
8888 if (1 == delimiters.size())
8900 return insert_count;
8903 template <
typename InputIterator,
8906 template <
typename,
typename>
class Sequence>
8907 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8909 const std::size_t& n,
8910 Sequence<T,Allocator>& sequence,
8913 return parse(range.first,range.second,delimiters,n,sequence,split_option);
8916 template <
typename InputIterator,
8918 typename Comparator,
8920 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8922 const std::size_t& n,
8923 std::set<T,Comparator,Allocator>& set,
8926 return parse(range.first,range.second,delimiters,n,set,split_option);
8929 template <
typename InputIterator,
8931 typename Comparator,
8933 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8935 const std::size_t& n,
8936 std::multiset<T,Comparator,Allocator>& multiset,
8939 return parse(range.first,range.second,delimiters,n,multiset,split_option);
8942 template <
typename InputIterator,
8945 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8947 const std::size_t& n,
8948 std::queue<T,Container>& queue,
8951 return parse(range.first,range.second,delimiters,n,queue,split_option);
8954 template <
typename InputIterator,
8957 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8959 const std::size_t& n,
8960 std::stack<T,Container>& stack,
8963 return parse(range.first,range.second,delimiters,n,stack,split_option);
8966 template <
typename InputIterator,
8969 typename Comparator>
8970 inline std::size_t
parse_n(
const std::pair<InputIterator,InputIterator>& range,
8972 const std::size_t& n,
8973 std::priority_queue<T,Container,Comparator>& priority_queue,
8976 return parse(range.first,range.second,delimiters,n,priority_queue,split_option);
8979 template <
typename T1,
typename T2,
typename T3,
typename T4,
8980 typename T5,
typename T6,
typename T7,
typename T8,
8981 typename T9,
typename T10,
typename T11,
typename T12>
8984 T1& t1, T2& t2, T3& t3, T4& t4,
8985 T5& t5, T6& t6, T7& t7, T8& t8,
8986 T9& t9, T10& t10, T11& t11, T12& t12)
8988 return parse(data.data(),
8989 data.data() + data.size(),
8991 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,
8995 template <
typename T1,
typename T2,
typename T3,
typename T4,
8996 typename T5,
typename T6,
typename T7,
typename T8,
8997 typename T9,
typename T10,
typename T11>
9000 T1& t1, T2& t2, T3& t3, T4& t4,
9001 T5& t5, T6& t6, T7& t7, T8& t8,
9002 T9& t9, T10& t10, T11& t11)
9004 return parse(data.data(),
9005 data.data() + data.size(),
9007 t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,
9011 template <
typename T1,
typename T2,
typename T3,
typename T4,
9012 typename T5,
typename T6,
typename T7,
typename T8,
9013 typename T9,
typename T10>
9016 T1& t1, T2& t2, T3& t3, T4& t4,
9017 T5& t5, T6& t6, T7& t7, T8& t8,
9020 return parse(data.data(),
9021 data.data() + data.size(),
9023 t1,t2,t3,t4,t5,t6,t7,t8,t9,
9027 template <
typename T1,
typename T2,
typename T3,
typename T4,
9028 typename T5,
typename T6,
typename T7,
typename T8,
9032 T1& t1, T2& t2, T3& t3, T4& t4,
9033 T5& t5, T6& t6, T7& t7, T8& t8,
9036 return parse(data.data(),
9037 data.data() + data.size(),
9039 t1,t2,t3,t4,t5,t6,t7,t8,
9043 template <
typename T1,
typename T2,
typename T3,
typename T4,
9044 typename T5,
typename T6,
typename T7,
typename T8>
9047 T1& t1, T2& t2, T3& t3, T4& t4,
9048 T5& t5, T6& t6, T7& t7, T8& t8)
9050 return parse(data.data(),
9051 data.data() + data.size(),
9053 t1,t2,t3,t4,t5,t6,t7,
9057 template <
typename T1,
typename T2,
typename T3,
typename T4,
9058 typename T5,
typename T6,
typename T7>
9061 T1& t1, T2& t2, T3& t3, T4& t4,
9062 T5& t5, T6& t6, T7& t7)
9064 return parse(data.data(),
9065 data.data() + data.size(),
9071 template <
typename T1,
typename T2,
typename T3,
typename T4,
9072 typename T5,
typename T6>
9075 T1& t1, T2& t2, T3& t3, T4& t4,
9078 return parse(data.data(),
9079 data.data() + data.size(),
9085 template <
typename T1,
typename T2,
typename T3,
typename T4,
9089 T1& t1, T2& t2, T3& t3, T4& t4,
9092 return parse(data.data(),
9093 data.data() + data.size(),
9099 template <
typename T1,
typename T2,
typename T3,
typename T4>
9102 T1& t1, T2& t2, T3& t3, T4& t4)
9104 return parse(data.data(),
9105 data.data() + data.size(),
9111 template <
typename T1,
typename T2,
typename T3>
9114 T1& t1, T2& t2, T3& t3)
9116 return parse(data.data(),
9117 data.data() + data.size(),
9123 template <
typename T1,
typename T2>
9128 return parse(data.data(),
9129 data.data() + data.size(),
9135 template <
typename T>
9140 return parse(data.data(),
9141 data.data() + data.size(),
9146 template <
typename T,
9148 template <
typename,
typename>
class Sequence>
9151 Sequence<T,Allocator>& sequence,
9154 return parse(data.data(),
9155 data.data() + data.size(),
9161 template <
typename T,
9162 typename Comparator,
9166 std::set<T,Comparator,Allocator>& set,
9169 return parse(data.data(),
9170 data.data() + data.size(),
9176 template <
typename T,
9177 typename Comparator,
9181 std::multiset<T,Comparator,Allocator>& multiset,
9184 return parse(data.data(),
9185 data.data() + data.size(),
9191 template <
typename T,
9195 std::queue<T,Container>& queue,
9198 return parse(data.data(),
9199 data.data() + data.size(),
9205 template <
typename T,
9209 std::stack<T,Container>& stack,
9212 return parse(data.data(),
9213 data.data() + data.size(),
9219 template <
typename T,
9221 typename Comparator>
9224 std::priority_queue<T,Container,Comparator>& priority_queue,
9227 return parse(data.data(),
9228 data.data() + data.size(),
9234 template <
typename T,
9236 template <
typename,
typename>
class Sequence>
9237 inline std::size_t
parse(
const int& argc,
char* argv[],
9238 Sequence<T,Allocator>& sequence,
9239 const bool break_on_fail =
true)
9242 for (
int i = 0; i < argc; ++i)
9251 sequence.push_back(tmp);
9256 template <
typename T1,
typename T2,
typename T3,
typename T4,
9257 typename T5,
typename T6,
typename T7,
typename T8,
9259 inline std::size_t
parse(
const int& argc,
char* argv[],
9260 T1& t1, T2& t2, T3& t3, T4& t4,
9261 T5& t5, T6& t6, T7& t7, T8& t8,
9265 if (9 != argc)
return 0;
9266 std::size_t result = 0;
9279 template <
typename T1,
typename T2,
typename T3,
typename T4,
9280 typename T5,
typename T6,
typename T7,
typename T8>
9281 inline std::size_t
parse(
const int& argc,
char* argv[],
9282 T1& t1, T2& t2, T3& t3, T4& t4,
9283 T5& t5, T6& t6, T7& t7, T8& t8)
9286 if (8 != argc)
return 0;
9287 std::size_t result = 0;
9299 template <
typename T1,
typename T2,
typename T3,
typename T4,
9300 typename T5,
typename T6,
typename T7>
9301 inline std::size_t
parse(
const int& argc,
char* argv[],
9302 T1& t1, T2& t2, T3& t3, T4& t4,
9303 T5& t5, T6& t6, T7& t7)
9306 if (7 != argc)
return 0;
9307 std::size_t result = 0;
9318 template <
typename T1,
typename T2,
typename T3,
typename T4,
9319 typename T5,
typename T6>
9320 inline std::size_t
parse(
const int& argc,
char* argv[],
9321 T1& t1, T2& t2, T3& t3, T4& t4,
9325 if (6 != argc)
return 0;
9326 std::size_t result = 0;
9336 template <
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
9337 inline std::size_t
parse(
const int& argc,
char* argv[],
9338 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
9340 if (5 != argc)
return 0;
9341 std::size_t result = 0;
9350 template <
typename T1,
typename T2,
typename T3,
typename T4>
9351 inline std::size_t
parse(
const int& argc,
char* argv[],
9352 T1& t1, T2& t2, T3& t3, T4& t4)
9354 if (4 != argc)
return 0;
9355 std::size_t result = 0;
9363 template <
typename T1,
typename T2,
typename T3>
9364 inline std::size_t
parse(
const int& argc,
char* argv[],
9365 T1& t1, T2& t2, T3& t3)
9367 if (3 != argc)
return 0;
9368 std::size_t result = 0;
9375 template <
typename T1,
typename T2>
9376 inline std::size_t
parse(
const int& argc,
char* argv[],
9379 if (2 != argc)
return 0;
9380 std::size_t result = 0;
9386 template <
typename T1>
9387 inline std::size_t
parse(
const int& argc,
char* argv[],
9390 if (1 != argc)
return 0;
9391 std::size_t result = 0;
9396 #define strtk_parse_begin(Type)\
9398 bool parse(const std::string& data, const std::string& delimiters, Type& t)\
9399 { return parse(data,delimiters
9401 #define strtk_parse_type(T)\
9404 #define strtk_parse_hex_type(T)\
9407 #define strtk_parse_ignore_token()\
9410 #define strtk_parse_end()\
9413 template <
typename T,
9415 template <
typename,
typename>
class Sequence>
9418 const std::size_t& n,
9419 Sequence<T,Allocator>& sequence,
9423 data.data() + data.size(),
9430 template <
typename T,
9431 typename Comparator,
9435 const std::size_t& n,
9436 std::set<T,Comparator,Allocator>& set,
9440 data.data() + data.size(),
9447 template <
typename T,
9448 typename Comparator,
9452 const std::size_t& n,
9453 std::multiset<T,Comparator,Allocator>& multiset,
9457 data.data() + data.size(),
9464 template <
typename T,
9468 const std::size_t& n,
9469 std::queue<T,Container>& queue,
9473 data.data() + data.size(),
9480 template <
typename T,
9484 const std::size_t& n,
9485 std::stack<T,Container>& stack,
9489 data.data() + data.size(),
9496 template <
typename T,
9498 typename Comparator>
9501 const std::size_t& n,
9502 std::priority_queue<T,Container,Comparator>& priority_queue,
9506 data.data() + data.size(),
9513 template <
typename T>
9516 const std::size_t& n,
9521 data.data() + data.size(),
9528 template <
typename T1,
typename T2,
typename T3,
typename T4,
9529 typename T5,
typename T6,
typename T7,
typename T8,
9530 typename T9,
typename T10,
typename T11,
typename T12>
9533 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9534 T7& t7, T8& t8, T9& t9, T10& t10, T11& t11, T12& t12)
9539 data.reserve(strtk::one_kilobyte);
9540 if (!std::getline(stream,data))
9542 if (data.empty() || delimiters.empty())
9545 data.data() + data.size(),
9548 t7,t8,t9,t10,t11,t12);
9551 template <
typename T1,
typename T2,
typename T3,
typename T4,
9552 typename T5,
typename T6,
typename T7,
typename T8,
9553 typename T9,
typename T10,
typename T11>
9556 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9557 T7& t7, T8& t8, T9& t9, T10& t10, T11& t11)
9562 data.reserve(strtk::one_kilobyte);
9563 if (!std::getline(stream,data))
9565 if (data.empty() || delimiters.empty())
9568 data.data() + data.size(),
9574 template <
typename T1,
typename T2,
typename T3,
typename T4,
9575 typename T5,
typename T6,
typename T7,
typename T8,
9576 typename T9,
typename T10>
9579 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9580 T7& t7, T8& t8, T9& t9, T10& t10)
9585 data.reserve(strtk::one_kilobyte);
9586 if (!std::getline(stream,data))
9588 if (data.empty() || delimiters.empty())
9591 data.data() + data.size(),
9597 template <
typename T1,
typename T2,
typename T3,
typename T4,
9598 typename T5,
typename T6,
typename T7,
typename T8,
9602 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9603 T7& t7, T8& t8, T9& t9)
9608 data.reserve(strtk::one_kilobyte);
9609 if (!std::getline(stream,data))
9611 if (data.empty() || delimiters.empty())
9614 data.data() + data.size(),
9620 template <
typename T1,
typename T2,
typename T3,
typename T4,
9621 typename T5,
typename T6,
typename T7,
typename T8>
9624 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9630 data.reserve(strtk::one_kilobyte);
9631 if (!std::getline(stream,data))
9633 if (data.empty() || delimiters.empty())
9636 data.data() + data.size(),
9642 template <
typename T1,
typename T2,
typename T3,
typename T4,
9643 typename T5,
typename T6,
typename T7>
9646 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
9652 data.reserve(strtk::one_kilobyte);
9653 if (!std::getline(stream,data))
9655 if (data.empty() || delimiters.empty())
9658 data.data() + data.size(),
9660 t1,t2,t3,t4,t5,t6,t7);
9663 template <
typename T1,
typename T2,
typename T3,
typename T4,
9664 typename T5,
typename T6>
9667 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6)
9672 data.reserve(strtk::one_kilobyte);
9673 if (!std::getline(stream,data))
9675 if (data.empty() || delimiters.empty())
9678 data.data() + data.size(),
9683 template <
typename T1,
typename T2,
typename T3,
typename T4,
9687 T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
9692 data.reserve(strtk::one_kilobyte);
9693 if (!std::getline(stream,data))
9695 if (data.empty() || delimiters.empty())
9698 data.data() + data.size(),
9703 template <
typename T1,
typename T2,
typename T3,
typename T4>
9706 T1& t1, T2& t2, T3& t3, T4& t4)
9711 data.reserve(strtk::one_kilobyte);
9712 if (!std::getline(stream,data))
9714 if (data.empty() || delimiters.empty())
9717 data.data() + data.size(),
9722 template <
typename T1,
typename T2,
typename T3>
9725 T1& t1, T2& t2, T3& t3)
9730 data.reserve(strtk::one_kilobyte);
9731 if (!std::getline(stream,data))
9733 if (data.empty() || delimiters.empty())
9736 data.data() + data.size(),
9741 template <
typename T1,
typename T2>
9749 data.reserve(strtk::one_kilobyte);
9750 if (!std::getline(stream,data))
9752 if (data.empty() || delimiters.empty())
9755 data.data() + data.size(),
9760 template <
typename T1>
9768 data.reserve(strtk::one_kilobyte);
9769 if (!std::getline(stream,data))
9771 if (data.empty() || delimiters.empty())
9774 data.data() + data.size(),
9779 template <
typename T,
9781 template <
typename,
typename>
class Sequence>
9784 Sequence<T,Allocator>& sequence,
9790 data.reserve(strtk::one_kilobyte);
9791 if (!std::getline(stream,data))
9793 if (data.empty() || delimiters.empty())
9796 data.data() + data.size(),
9802 template <
typename T,
9803 typename Comparator,
9807 std::set<T,Comparator,Allocator>& set,
9813 data.reserve(strtk::one_kilobyte);
9814 if (!std::getline(stream,data))
9816 if (data.empty() || delimiters.empty())
9819 data.data() + data.size(),
9825 template <
typename T,
9826 typename Comparator,
9830 std::multiset<T,Comparator,Allocator>& multiset,
9836 data.reserve(strtk::one_kilobyte);
9837 if (!std::getline(stream,data))
9839 if (data.empty() || delimiters.empty())
9842 data.data() + data.size(),
9848 template <
typename T,
9852 std::queue<T,Container>& queue,
9858 data.reserve(strtk::one_kilobyte);
9859 if (!std::getline(stream,data))
9861 if (data.empty() || delimiters.empty())
9864 data.data() + data.size(),
9870 template <
typename T,
9874 std::stack<T,Container>& stack,
9880 data.reserve(strtk::one_kilobyte);
9881 if (!std::getline(stream,data))
9883 if (data.empty() || delimiters.empty())
9886 data.data() + data.size(),
9892 template <
typename T,
9894 typename Comparator>
9897 std::priority_queue<T,Container,Comparator>& priority_queue,
9904 data.reserve(strtk::one_kilobyte);
9905 if (!std::getline(stream,data))
9907 if (data.empty() || delimiters.empty())
9910 data.data() + data.size(),
9916 template <
typename T,
9918 template <
typename,
typename>
class Sequence>
9921 const std::size_t& n,
9922 Sequence<T,Allocator>& sequence,
9928 data.reserve(strtk::one_kilobyte);
9929 if (!std::getline(stream,data))
9931 if (data.empty() || delimiters.empty())
9934 data.data() + data.size(),
9941 template <
typename T,
9942 typename Comparator,
9946 const std::size_t& n,
9947 std::set<T,Comparator,Allocator>& set,
9953 data.reserve(strtk::one_kilobyte);
9954 if (!std::getline(stream,data))
9956 if (data.empty() || delimiters.empty())
9959 data.data() + data.size(),
9966 template <
typename T,
9967 typename Comparator,
9971 const std::size_t& n,
9972 std::multiset<T,Comparator,Allocator>& multiset,
9978 data.reserve(strtk::one_kilobyte);
9979 if (!std::getline(stream,data))
9981 if (data.empty() || delimiters.empty())
9984 data.data() + data.size(),
9991 template <
typename T,
9995 const std::size_t& n,
9996 std::queue<T,Container>& queue,
10002 data.reserve(strtk::one_kilobyte);
10003 if (!std::getline(stream,data))
10005 if (data.empty() || delimiters.empty())
10008 data.data() + data.size(),
10015 template <
typename T,
10016 typename Container>
10019 const std::size_t& n,
10020 std::stack<T,Container>& stack,
10026 data.reserve(strtk::one_kilobyte);
10027 if (!std::getline(stream,data))
10029 if (data.empty() || delimiters.empty())
10032 data.data() + data.size(),
10039 template <
typename T,
10040 typename Container,
10041 typename Comparator>
10044 const std::size_t& n,
10045 std::priority_queue<T,Container,Comparator>& priority_queue,
10052 data.reserve(strtk::one_kilobyte);
10053 if (!std::getline(stream,data))
10055 if (data.empty() || delimiters.empty())
10058 data.data() + data.size(),
10065 template <
typename T1,
typename T2,
typename T3,
typename T4,
10066 typename T5,
typename T6,
typename T7,
typename T8,
10067 typename T9,
typename T10,
typename T11,
typename T12>
10070 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10071 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
10072 const T9& t9,
const T10& t10,
const T11& t11,
const T12& t12)
10088 template <
typename T1,
typename T2,
typename T3,
typename T4,
10089 typename T5,
typename T6,
typename T7,
typename T8,
10090 typename T9,
typename T10,
typename T11>
10093 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10094 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
10095 const T9& t9,
const T10& t10,
const T11& t11)
10110 template <
typename T1,
typename T2,
typename T3,
typename T4,
10111 typename T5,
typename T6,
typename T7,
typename T8,
10112 typename T9,
typename T10>
10115 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10116 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
10117 const T9& t9,
const T10& t10)
10131 template <
typename T1,
typename T2,
typename T3,
typename T4,
10132 typename T5,
typename T6,
typename T7,
typename T8,
10136 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10137 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
10151 template <
typename T1,
typename T2,
typename T3,
typename T4,
10152 typename T5,
typename T6,
typename T7,
typename T8>
10155 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10156 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8)
10168 template <
typename T1,
typename T2,
typename T3,
typename T4,
10169 typename T5,
typename T6,
typename T7>
10172 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10173 const T5& t5,
const T6& t6,
const T7& t7)
10184 template <
typename T1,
typename T2,
typename T3,
typename T4,
10185 typename T5,
typename T6>
10188 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10189 const T5& t5,
const T6& t6)
10199 template <
typename T1,
typename T2,
typename T3,
typename T4,
10203 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
10213 template <
typename T1,
typename T2,
typename T3,
typename T4>
10216 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4)
10224 template <
typename T1,
typename T2,
typename T3>
10227 const T1& t1,
const T2& t2,
const T3& t3)
10234 template <
typename T1,
typename T2>
10237 const T1& t1,
const T2& t2)
10243 template <
typename InputIterator>
10246 const InputIterator begin,
10247 const InputIterator end)
10249 InputIterator itr = begin;
10253 if (end == (++itr))
10256 output += delimiter;
10260 template <
typename InputIterator>
10263 const std::pair<InputIterator,InputIterator>& range)
10265 InputIterator itr = range.first;
10266 while (range.second != itr)
10269 if (range.second == (++itr))
10272 output += delimiter;
10276 template <
typename T,
10277 typename Allocator,
10278 template <
typename,
typename>
class Sequence>
10281 const Sequence<T,Allocator>& sequence)
10283 join(output,delimiter,sequence.begin(),sequence.end());
10286 template <
typename T,
10287 typename Comparator,
10288 typename Allocator>
10291 const std::set<T,Comparator,Allocator>& set)
10293 join(output,delimiter,set.begin(),set.end());
10296 template <
typename T,
10297 typename Comparator,
10298 typename Allocator>
10301 const std::multiset<T,Comparator,Allocator>& multiset)
10303 join(output,delimiter,multiset.begin(),multiset.end());
10308 int argc,
char* argv[])
10310 for (
int i = 0; i < argc; ++i)
10313 if (i < (argc - 1))
10314 output += delimiter;
10318 template <
typename InputIterator>
10320 const InputIterator begin,
10321 const InputIterator end)
10324 output.reserve(one_kilobyte);
10325 join(output,delimiter,begin,end);
10329 template <
typename InputIterator>
10331 const std::pair<InputIterator,InputIterator>& range)
10334 output.reserve(one_kilobyte);
10335 join(output,delimiter,range.first,range.second);
10339 template <
typename T,
10340 typename Allocator,
10341 template <
typename,
typename>
class Sequence>
10343 const Sequence<T,Allocator>& sequence)
10345 if (sequence.empty())
10348 return join(delimiter,sequence.begin(),sequence.end());
10351 template <
typename T,
10352 typename Comparator,
10353 typename Allocator>
10355 const std::set<T,Comparator,Allocator>& set)
10360 return join(delimiter,set.begin(),set.end());
10363 template <
typename T,
10364 typename Comparator,
10365 typename Allocator>
10367 const std::multiset<T,Comparator,Allocator>& multiset)
10369 if (multiset.empty())
10372 return join(delimiter,multiset.begin(),multiset.end());
10378 result.reserve(one_kilobyte);
10379 join(result,delimiter,argc,argv);
10383 template <
typename InputIterator,
typename Predicate>
10386 Predicate predicate,
10387 const InputIterator begin,
10388 const InputIterator end)
10390 InputIterator itr = begin;
10391 bool first_time =
true;
10394 if (predicate(*itr))
10397 output += delimiter;
10399 first_time =
false;
10402 if (end == (++itr))
10407 template <
typename InputIterator,
typename Predicate>
10410 Predicate predicate,
10411 const std::pair<InputIterator,InputIterator>& range)
10413 InputIterator itr = range.first;
10414 bool first_time =
true;
10415 while (range.second != itr)
10417 if (predicate(*itr))
10420 output += delimiter;
10422 first_time =
false;
10425 if (range.second == (++itr))
10430 template <
typename T,
10431 typename Predicate,
10432 typename Allocator,
10433 template <
typename,
typename>
class Sequence>
10436 Predicate predicate,
10437 const Sequence<T,Allocator>& sequence)
10439 join_if(output,delimiter,predicate,sequence.begin(),sequence.end());
10442 template <
typename T,
10443 typename Predicate,
10444 typename Comparator,
10445 typename Allocator>
10448 Predicate predicate,
10449 const std::set<T,Comparator,Allocator>& set)
10451 join_if(output,delimiter,predicate,set.begin(),set.end());
10454 template <
typename T,
10455 typename Predicate,
10456 typename Comparator,
10457 typename Allocator>
10460 Predicate predicate,
10461 const std::multiset<T,Comparator,Allocator>& multiset)
10463 join_if(output,delimiter,predicate,multiset.begin(),multiset.end());
10466 template <
typename InputIterator,
typename Predicate>
10468 Predicate predicate,
10469 const InputIterator begin,
10470 const InputIterator end)
10473 output.reserve(one_kilobyte);
10474 join_if(output,delimiter,predicate,begin,end);
10478 template <
typename InputIterator,
typename Predicate>
10480 Predicate predicate,
10481 const std::pair<InputIterator,InputIterator>& range)
10484 output.reserve(one_kilobyte);
10485 join_if(output,delimiter,predicate,range.first,range.second);
10489 template <
typename T,
10490 typename Predicate,
10491 typename Allocator,
10492 template <
typename,
typename>
class Sequence>
10494 Predicate predicate,
10495 const Sequence<T,Allocator>& sequence)
10497 return join(delimiter,predicate,sequence.begin(),sequence.end());
10500 template <
typename T,
10501 typename Predicate,
10502 typename Comparator,
10503 typename Allocator>
10505 Predicate predicate,
10506 const std::set<T,Comparator,Allocator>& set)
10508 return join_if(delimiter,predicate,set.begin(),set.end());
10511 template <
typename T,
10512 typename Predicate,
10513 typename Comparator,
10514 typename Allocator>
10516 Predicate predicate,
10517 const std::multiset<T,Comparator,Allocator>& multiset)
10519 return join_if(delimiter,predicate,multiset.begin(),multiset.end());
10528 data_.reserve(initial_size);
10531 template <
typename T>
10548 inline operator const char* ()
const
10550 return data_.data();
10562 if (0 == n)
return;
10563 output.reserve(output.size() + (str.size() * n));
10564 for (std::size_t i = 0; i < n; ++i)
10566 output.append(str);
10582 str.reserve(str.size() + (str.size() * n));
10584 for (std::size_t i = 0; i < n; ++i)
10586 str.append(temp_str);
10590 template <
typename InputIterator>
10594 const InputIterator begin,
10595 const InputIterator end)
10597 InputIterator itr = begin;
10599 s.reserve(one_kilobyte);
10611 template <
typename T,
10612 typename Allocator,
10613 template <
typename,
typename>
class Sequence>
10617 Sequence<T,Allocator>& sequence)
10619 bracketize(output,pre,post,sequence.begin(),sequence.end());
10622 template <
typename T,
10623 typename Comparator,
10624 typename Allocator>
10628 std::set<T,Comparator,Allocator>& set)
10630 bracketize(output,pre,post,set.begin(),set.end());
10633 template <
typename T,
10634 typename Comparator,
10635 typename Allocator>
10639 std::multiset<T,Comparator,Allocator>& multiset)
10641 bracketize(output,pre,post,multiset.begin(),multiset.end());
10644 template <
typename InputIterator>
10647 const InputIterator begin,
10648 const InputIterator end)
10651 output.reserve(one_kilobyte);
10656 template <
typename T,
10657 typename Allocator,
10658 template <
typename,
typename>
class Sequence>
10661 Sequence<T,Allocator>& sequence)
10663 return bracketize(pre,post,sequence.begin(),sequence.end());
10666 template <
typename T,
10667 typename Comparator,
10668 typename Allocator>
10671 std::set<T,Comparator,Allocator>& set)
10673 return bracketize(pre,post,set.begin(),set.end());
10676 template <
typename T,
10677 typename Comparator,
10678 typename Allocator>
10681 std::multiset<T,Comparator,Allocator>& multiset)
10683 return bracketize(pre,post,multiset.begin(),multiset.end());
10686 template <
typename T>
10693 interval_(interval),
10699 if (++count_ == interval_)
10715 std::size_t count_;
10716 std::size_t interval_;
10720 template <
typename Inserter,
10721 typename InputIterator,
10724 const InputIterator begin,
const InputIterator end,
10727 std::size_t size = 0;
10728 InputIterator itr = begin;
10745 template <
typename Iterator,
typename T>
10746 inline void iota(Iterator begin, Iterator end,
T value)
10748 Iterator itr = begin;
10756 template <
typename T>
10762 template <
typename T,
10763 typename Allocator,
10764 template <
typename,
typename>
class Sequence>
10765 inline void iota(Sequence<T,Allocator>& sequence, std::size_t count,
T value)
10769 sequence.push_back(value++);
10774 template <
typename T,
10775 typename Comparator,
10776 typename Allocator>
10777 inline void iota(std::set<T,Comparator,Allocator>& set, std::size_t count,
T value)
10781 set.insert(value++);
10786 template <
typename T,
10787 typename Comparator,
10788 typename Allocator>
10789 inline void iota(std::multiset<T,Comparator,Allocator>& multiset, std::size_t count,
T value)
10793 multiset.insert(value++);
10798 template <
typename OutputIterator,
typename T>
10809 template <
typename T,
10810 typename Allocator,
10811 template <
typename,
typename>
class Sequence>
10812 inline void iota(Sequence<T,Allocator>& sequence,
const T& value)
10814 strtk::iota(sequence.begin(),sequence.end(),value);
10817 template <
typename T,
10818 typename Comparator,
10819 typename Allocator>
10820 inline void iota(std::set<T,Comparator,Allocator>& set,
const T& value)
10825 template <
typename T,
10826 typename Comparator,
10827 typename Allocator>
10828 inline void iota(std::multiset<T,Comparator,Allocator>& multiset,
const T& value)
10830 strtk::iota(multiset.begin(),multiset.end(),value);
10833 template <
typename InputIterator,
typename OutputIterator>
10834 inline void cut(
const std::size_t& r0,
const std::size_t& r1,
10835 const InputIterator begin, InputIterator end,
10839 InputIterator itr = begin;
10846 (*out++) = s.substr(r0,std::min(r1,s.size()) - r0);
10850 template <
typename Allocator,
10851 template <
typename,
typename>
class Sequence,
10853 inline void cut(
const std::size_t& r0,
const std::size_t& r1,
10854 const Sequence<std::string, Allocator>& sequence,
10857 cut(r0,r1,sequence.begin(),sequence.end(),out);
10860 template <
typename Iterator>
10862 const Iterator begin,
const Iterator end)
10865 Iterator itr = begin;
10868 if ((*itr).size() >= r0)
10870 (*itr) = (*itr).substr(r0,std::min(r1,(*itr).size()) - r0);
10876 template <
typename Allocator,
10877 template <
typename,
typename>
class Sequence>
10878 inline void cut(
const std::size_t& r0,
const std::size_t& r1,
10879 const Sequence<std::string, Allocator>& sequence)
10881 cut(r0,r1,sequence.begin(),sequence.end());
10884 template <
typename Comparator,
typename Allocator>
10885 inline void cut(
const std::size_t& r0,
const std::size_t& r1,
10886 const std::set<std::string, Comparator, Allocator>& set)
10888 cut(r0,r1,set.begin(),set.end());
10891 template <
typename Comparator,
typename Allocator>
10892 inline void cut(
const std::size_t& r0,
const std::size_t& r1,
10893 const std::multiset<std::string, Comparator, Allocator>& multiset)
10895 cut(r0,r1,multiset.begin(),multiset.end());
10904 if (itable.size() != otable.size())
10906 throw std::runtime_error(
"translation_table() - Input/Output table size mismatch.");
10908 strtk::iota(table_, table_ + 256, static_cast<unsigned char>(0));
10909 for (std::size_t i = 0; i < itable.size(); ++i)
10911 table_[
static_cast<unsigned int>(itable[i])] = static_cast<unsigned char>(otable[i]);
10917 return static_cast<char>(table_[
static_cast<unsigned int>(c)]);
10922 return static_cast<unsigned char>(table_[
static_cast<unsigned int>(c)]);
10927 unsigned char table_[256];
10933 std::transform(result.begin(),result.end(),result.begin(),trans_table);
10939 std::transform(s.begin(),s.end(),s.begin(),trans_table);
10942 #ifdef strtk_enable_random
10944 std::size_t length,
10945 unsigned int pre_gen_cnt = 0,
10946 unsigned int seed = magic_seed)
10948 boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
10949 boost::uniform_int<unsigned int> dist(std::numeric_limits<unsigned int>::min(),std::numeric_limits<unsigned int>::max());
10950 boost::variate_generator<boost::mt19937&, boost::uniform_int<unsigned int> > rnd(rng,dist);
10952 if (pre_gen_cnt > 0)
10954 while (pre_gen_cnt--) rnd();
10957 unsigned char* itr = data;
10958 unsigned int* x = 0;
10959 while (length >=
sizeof(
unsigned int))
10961 x =
reinterpret_cast<unsigned int*
>(itr);
10963 itr +=
sizeof(
unsigned int);
10964 length -=
sizeof(
unsigned int);
10969 itr -= (
sizeof(
unsigned int) - length);
10970 x =
reinterpret_cast<unsigned int*
>(itr);
10982 #define strtk_register_rand_int_type_tag(T)\
10983 template<> struct supported_random_type<T> { typedef rand_int_type_tag type; enum { value = true }; };
10985 #define strtk_register_rand_real_type_tag(T)\
10986 template<> struct supported_random_type<T> { typedef rand_real_type_tag type; enum { value = true }; };
11002 #undef strtk_register_rand_int_type_tag
11003 #undef strtk_register_rand_real_type_tag
11005 template <
typename T,
typename OutputIterator,
typename RandomNumberGenerator>
11010 RandomNumberGenerator& rng,
11014 using namespace boost;
11015 variate_generator<RandomNumberGenerator&,uniform_int<T> > rnd(rng,uniform_int<T>(min,max));
11016 for (std::size_t i = 0; i < count; ++i, *out++ = rnd()) ;
11019 template <
typename T,
typename OutputIterator,
typename RandomNumberGenerator>
11024 RandomNumberGenerator& rng,
11028 using namespace boost;
11029 variate_generator<RandomNumberGenerator&, uniform_real<T> > rnd(rng,uniform_real<T>(min,max));
11030 for (std::size_t i = 0; i < count; ++i, *out++ = rnd()) ;
11039 typedef boost::mt19937 rng_type;
11040 typedef boost::variate_generator<rng_type, boost::uniform_real<double> > variate_type;
11045 std::size_t pregen = 0)
11046 : rng_(static_cast<rng_type::result_type>(seed)),
11047 rnd_(rng_,boost::uniform_real<double>(0.0,1.0))
11049 while (pregen--) rng_();
11063 template <
typename T,
typename OutputIterator>
11068 const std::size_t& seed = magic_seed,
11069 const std::size_t& pregen = 0)
11072 boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
11073 for (std::size_t i = 0; i++ < pregen; rng()) ;
11077 template <
typename T,
11078 typename Allocator,
11079 template <
typename,
typename>
class Sequence>
11083 Sequence<T,Allocator>& sequence,
11084 const std::size_t& seed = magic_seed,
11085 const std::size_t& pregen = 0)
11088 boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
11089 for (std::size_t i = 0; i++ < pregen; rng()) ;
11093 template <
typename Iterator,
11094 typename RandomNumberGenerator,
11097 RandomNumberGenerator& rng,
11101 if ((rng. min() < 0.0) || (rng.max() > 1.0))
return;
11102 std::deque<std::size_t> index;
11103 for (std::size_t i = 0; i < size; index.push_back(i++)) ;
11104 while (!index.empty())
11106 std::size_t idx =
static_cast<std::size_t
>(index.size() * rng());
11107 (*out) = *(begin + index[idx]);
11108 index.erase(index.begin() + idx);
11113 template <
typename Iterator,
11117 const std::size_t& seed = magic_seed,
11118 const std::size_t& pregen = 0)
11120 boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
11121 for (std::size_t i = 0; i++ < pregen; rng()) ;
11122 boost::uniform_real<double> dist(0.0,1.0);
11123 boost::variate_generator<boost::mt19937&, boost::uniform_real<double> > rnd(rng,dist);
11127 template <
typename T,
11128 typename Allocator,
11129 template <
typename,
typename>
class Sequence,
11133 const std::size_t& seed = magic_seed,
11134 const std::size_t& pregen = 0)
11139 template <
typename Iterator,
11140 typename RandomNumberGenerator,
11143 std::size_t set_size,
11144 RandomNumberGenerator& rng,
11148 if ((size < set_size) || (rng. min() < 0.0) || (rng.max() > 1.0))
return false;
11149 std::deque<std::size_t> index;
11150 for (std::size_t i = 0; i < size; index.push_back(i++)) ;
11153 std::size_t idx =
static_cast<std::size_t
>(index.size() * rng());
11154 (*out) = *(begin + index[idx]);
11155 index.erase(index.begin() + idx);
11162 template <
typename Iterator,
11165 const std::size_t& set_size,
11167 const std::size_t& seed = magic_seed,
11168 const std::size_t& pregen = 0)
11170 boost::mt19937 rng(static_cast<boost::mt19937::result_type>(seed));
11171 for (std::size_t i = 0; i++ < pregen; rng()) ;
11172 boost::uniform_real<double> dist(0.0,1.0);
11173 boost::variate_generator<boost::mt19937&, boost::uniform_real<double> > rnd(rng,dist);
11177 template <
typename T,
11178 typename Allocator,
11179 template <
typename,
typename>
class Sequence,
11182 const std::size_t& set_size,
11184 const std::size_t& seed = magic_seed,
11185 const std::size_t& pregen = 0)
11190 template <
typename Iterator,
11192 typename RandomNumberGenerator>
11194 const std::size_t k,
11195 OutputIterator out,
11196 RandomNumberGenerator& rng)
11198 typedef typename std::iterator_traits<Iterator>::value_type
T;
11199 std::vector<T> selection;
11200 selection.resize(k);
11201 Iterator itr = begin;
11202 std::size_t index = 0;
11203 while ((index < k) && (end != itr))
11205 selection[index] = (*itr);
11211 else if (index < k)
11213 std::copy(selection.begin(),selection.begin() + index, out);
11219 if (rng() < (k / n))
11221 selection[
static_cast<std::size_t
>(rng() * k)] = (*itr);
11226 std::copy(selection.begin(),selection.end(),out);
11230 template <
typename Iterator,
11232 typename RandomNumberGenerator>
11234 OutputIterator out,
11235 RandomNumberGenerator& rng)
11237 typedef typename std::iterator_traits<Iterator>::value_type
T;
11241 Iterator itr = begin;
11245 if (rng() < (1.0 / ++n))
11247 selection = (*itr);
11251 (*out) = selection;
11254 #endif // strtk_enable_random
11256 template <
typename Iterator>
11260 if ((first == last) || (first == k) || (last == k))
11262 Iterator itr1 = first;
11263 Iterator itr2 = last;
11271 while (first != itr1)
11273 if (*--itr1 < (*itr2))
11276 while (!((*itr1) < (*j))) ++j;
11277 std::iter_swap(itr1,j);
11281 std::rotate(itr1,j,last);
11287 std::rotate(k,itr2,last);
11291 std::rotate(first,k,last);
11295 template <
typename T,
11296 typename Allocator,
11297 template <
typename,
typename>
class Sequence>
11300 return next_combination(sequence.begin(), sequence.begin() + size, sequence.end());
11303 template <
typename Iterator,
typename Function>
11308 function(begin,end);
11310 while (std::next_permutation(begin,end));
11313 template <
typename Iterator,
typename Function>
11318 if (!
function(begin,end))
11321 while (std::next_permutation(begin,end));
11334 template <
typename Iterator>
11335 static inline void rotate_discontinuous(Iterator first1, Iterator last1,
11336 typename std::iterator_traits<Iterator>::difference_type d1,
11337 Iterator first2, Iterator last2,
11338 typename std::iterator_traits<Iterator>::difference_type d2)
11342 std::rotate(first2, std::swap_ranges(first1, last1, first2), last2);
11345 Iterator i1 = last1;
11346 while (first2 != last2)
11348 swap(*--i1,*--last2);
11350 std::rotate(first1, i1, last1);
11354 template <
typename Iterator,
class Function>
11355 inline void combine_discontinuous(Iterator first1, Iterator last1,
typename std::iterator_traits<Iterator>::difference_type d1,
11356 Iterator first2, Iterator last2,
typename std::iterator_traits<Iterator>::difference_type d2,
11358 typename std::iterator_traits<Iterator>::difference_type d = 0)
11360 typedef typename std::iterator_traits<Iterator>::difference_type D;
11362 if ((0 == d1) || (0 == d2))
11366 Iterator i2 = first2;
11367 while (i2 != last2)
11370 swap(*first1, *i2);
11376 Iterator f1p = first1;
11377 std::advance(f1p,1);
11378 Iterator i2 = first2;
11380 while (i2 != last2)
11383 swap(*first1, *i2);
11391 Iterator f2p = first2;
11392 std::advance(f2p,1);
11393 rotate_discontinuous(first1, last1, d1, f2p, last2, d2 - 1);
11396 rotate_discontinuous(first1, last1, d1, first2, last2, d2);
11399 template <
typename Iterator,
class Function>
11401 Iterator first2, Iterator last2,
typename std::iterator_traits<Iterator>::difference_type d2,
11403 typename std::iterator_traits<Iterator>::difference_type d = 0)
11405 typedef typename std::iterator_traits<Iterator>::difference_type D;
11407 if (d1 == 0 || d2 == 0)
11411 for (Iterator i2 = first2; i2 != last2; ++i2)
11415 swap(*first1, *i2);
11420 Iterator f1p = first1;
11421 std::advance(f1p,1);
11422 Iterator i2 = first2;
11423 for (D d22 = d2; i2 != last2; ++i2, --d22)
11427 swap(*first1, *i2);
11434 Iterator f2p = first2;
11435 std::advance(f2p,1);
11436 rotate_discontinuous(first1, last1, d1, f2p, last2, d2 - 1);
11439 rotate_discontinuous(first1, last1, d1, first2, last2, d2);
11443 template <
class Function,
typename Iterator>
11468 template <
class Function,
typename Iterator>
11481 return f_(first_,last_);
11495 template <
typename Iterator,
typename Function>
11497 const std::size_t& size,
11500 if (
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(size) >
std::distance(begin,end))
11502 Iterator mid = begin + size;
11511 template <
typename Iterator,
typename Function>
11513 const std::size_t& size,
11516 if (
static_cast<typename std::iterator_traits<Iterator>::difference_type
>(size) >
std::distance(begin,end))
11518 Iterator mid = begin + size;
11527 inline unsigned long long int n_choose_k(
const unsigned long long int& n,
const unsigned long long int& k)
11529 if (n < k)
return 0;
11530 if (0 == n)
return 0;
11531 if (0 == k)
return 1;
11532 if (n == k)
return 1;
11533 if (1 == k)
return n;
11535 typedef unsigned long long int value_type;
11537 class n_choose_k_impl
11541 n_choose_k_impl(value_type* table,
const value_type& dimension)
11543 dimension_(dimension / 2)
11546 inline value_type& lookup(
const value_type& n,
const value_type& k)
11548 const std::size_t difference =
static_cast<std::size_t
>(n - k);
11549 return table_[
static_cast<std::size_t
>((dimension_ * n) + std::min<value_type>(k,difference))];
11552 inline value_type compute(
const value_type& n,
const value_type& k)
11555 if ((0 == k) || (k == n))
11557 value_type v1 = lookup(n - 1,k - 1);
11559 v1 = lookup(n - 1,k - 1) = compute(n - 1,k - 1);
11560 value_type v2 = lookup(n - 1,k);
11562 v2 = lookup(n - 1,k) = compute(n - 1,k);
11566 value_type* table_;
11567 const value_type dimension_;
11571 inline n_choose_k_impl& operator=(
const n_choose_k_impl&)
11577 static const std::size_t static_table_dim = 100;
11578 static const std::size_t static_table_size =
static_cast<std::size_t
>((static_table_dim * static_table_dim) / 2);
11579 static value_type static_table[static_table_size];
11580 static bool static_table_initialized =
false;
11582 if (!static_table_initialized && (n <= static_table_dim))
11584 std::fill_n(static_table,static_table_size,0);
11585 static_table_initialized =
true;
11588 const std::size_t table_size =
static_cast<std::size_t
>(n * (n / 2) + (n & 1));
11590 unsigned long long int dimension = static_table_dim;
11591 value_type* table = 0;
11593 if (table_size <= static_table_size)
11594 table = static_table;
11598 table =
new value_type[table_size];
11599 std::fill_n(table,table_size,0ULL);
11602 value_type result = n_choose_k_impl(table,dimension).compute(n,k);
11604 if (table != static_table)
11612 const unsigned long long int max_n = 100ULL;
11613 for (
unsigned long long int n = 0; n < max_n; ++n)
11615 for (
unsigned long long int k = 0; k < max_n; ++k)
11622 template <
typename OutputIterator>
11624 const std::size_t& r,
11625 const std::size_t& k,
11626 OutputIterator out,
11627 const bool complete_index =
true)
11631 typedef unsigned long long int value_type;
11633 std::vector<std::size_t> index_list(k,0);
11638 for (std::size_t i = 1; i <= (k - 1); ++i)
11640 index_list[i - 1] = 0;
11643 index_list[i - 1] = index_list[i - 2];
11648 index_list[i - 1] += 1;
11649 j =
n_choose_k(r - index_list[i - 1], k - i);
11656 index_list[k - 1] = index_list[k - 2] +
static_cast<std::size_t
>(n) - static_cast<std::size_t>(x);
11657 for (std::size_t i = 0; i < index_list.size(); --index_list[i++]);
11659 std::copy(index_list.begin(),index_list.end(),out);
11661 if (complete_index)
11663 std::vector<unsigned int> exist_table(r,0);
11665 for (std::size_t i = 0; i < index_list.size(); ++i)
11667 exist_table[index_list[i]] = 1;
11670 for (std::size_t i = 0; i < exist_table.size(); ++i)
11672 if (0 == exist_table[i])
11681 template <
typename InputIterator,
typename OutputIterator>
11683 const std::size_t& k,
11684 const InputIterator begin,
11685 const InputIterator end,
11686 OutputIterator out,
11687 const bool complete_index =
true)
11690 std::vector<std::size_t> index_list;
11692 for (std::size_t i = 0; i < index_list.size(); ++i)
11694 (*out) = *(begin + index_list[i]);
11699 template <
typename OutputIterator>
11703 std::vector<std::size_t> factorid (k,0);
11704 std::vector<std::size_t> permutate(k,0);
11707 for (std::size_t i = 1; i < k; ++i)
11709 factorid[i] = factorid[i - 1] * i;
11712 for (std::size_t i = 0; i < k; ++i)
11714 permutate[i] = n / factorid[k - i - 1];
11715 n = n % factorid[k - i - 1];
11718 for (std::size_t i = k - 1; i > 0; --i)
11720 for (
int j = static_cast<int>(i - 1); j >= 0; --j)
11722 if (permutate[j] <= permutate[i])
11729 for (std::size_t i = 0; i < k; ++i)
11731 *(out++) = permutate[i];
11735 template <
typename InputIterator,
typename OutputIterator>
11737 const InputIterator begin,
11738 const InputIterator end,
11739 OutputIterator out)
11742 std::vector<std::size_t> index_list(size,0);
11744 for (std::size_t i = 0; i < size; ++i)
11746 *(out++) = (begin + index_list[i]);
11752 std::vector<std::size_t> index_list(s.size(),0);
11755 result.reserve(s.size());
11756 for (std::size_t i = 0; i < index_list.size(); ++i)
11758 result += s[index_list[i]];
11763 template <
typename Iterator>
11765 std::pair<Iterator,Iterator>,
11777 const bool sorted =
true)
11780 middle_(begin + k),
11781 current_combination_(begin_,middle_)
11789 template <
typename T,
11790 typename Allocator,
11791 template <
typename,
typename>
class Sequence>
11793 Sequence<T,Allocator>& seq,
11794 const bool sorted =
true)
11795 : begin_(seq.begin()),
11797 middle_(begin_ + k),
11798 current_combination_(begin_,middle_)
11808 const bool sorted =
true)
11809 : begin_(const_cast<char*>(str.data())),
11810 end_(const_cast<char*>(str.data() + str.size())),
11811 middle_(begin_ + k),
11812 current_combination_(begin_,middle_)
11824 current_combination_(end,end)
11828 : begin_(const_cast<char*>(str.data() + str.size())),
11831 current_combination_(end_,end_)
11834 template <
typename T,
11835 typename Allocator,
11836 template <
typename,
typename>
class Sequence>
11838 : begin_(seq.end()),
11841 current_combination_(end_,end_)
11846 if (begin_ != end_)
11850 begin_ = middle_ = end_;
11859 this->operator++();
11867 for (
int i = 0; i <
inc; ++i, ++(*this)) ;
11874 return current_combination_;
11879 return (begin_ == itr.
begin_ ) &&
11880 (end_ == itr.
end_ ) &&
11907 template <
typename Iterator,
int N>
11912 throw std::runtime_error(
"all_digits_check_impl - unsupported value for N.");
11916 template <
typename Iterator>
11921 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
11926 template <
typename Iterator>
11931 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
11936 template <
typename Iterator>
11941 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
11946 template <
typename Iterator>
11951 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
11952 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
11953 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
11954 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
11955 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
11956 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
11957 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
11958 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
11959 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
11960 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
11961 static_cast<unsigned char>(itr[10] -
'0') < 10 &&
11962 static_cast<unsigned char>(itr[11] -
'0') < 10 &&
11963 static_cast<unsigned char>(itr[12] -
'0') < 10 &&
11964 static_cast<unsigned char>(itr[13] -
'0') < 10 &&
11965 static_cast<unsigned char>(itr[14] -
'0') < 10 &&
11966 static_cast<unsigned char>(itr[15] -
'0') < 10;
11970 template <
typename Iterator>
11975 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
11976 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
11977 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
11978 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
11979 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
11980 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
11981 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
11982 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
11983 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
11984 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
11985 static_cast<unsigned char>(itr[10] -
'0') < 10 &&
11986 static_cast<unsigned char>(itr[11] -
'0') < 10 &&
11987 static_cast<unsigned char>(itr[12] -
'0') < 10 &&
11988 static_cast<unsigned char>(itr[13] -
'0') < 10 &&
11989 static_cast<unsigned char>(itr[14] -
'0') < 10;
11993 template <
typename Iterator>
11998 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
11999 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
12000 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
12001 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
12002 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
12003 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
12004 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
12005 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
12006 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
12007 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
12008 static_cast<unsigned char>(itr[10] -
'0') < 10 &&
12009 static_cast<unsigned char>(itr[11] -
'0') < 10 &&
12010 static_cast<unsigned char>(itr[12] -
'0') < 10 &&
12011 static_cast<unsigned char>(itr[13] -
'0') < 10;
12015 template <
typename Iterator>
12020 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
12021 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
12022 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
12023 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
12024 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
12025 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
12026 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
12027 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
12028 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
12029 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
12030 static_cast<unsigned char>(itr[10] -
'0') < 10 &&
12031 static_cast<unsigned char>(itr[11] -
'0') < 10 &&
12032 static_cast<unsigned char>(itr[12] -
'0') < 10;
12036 template <
typename Iterator>
12041 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
12042 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
12043 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
12044 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
12045 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
12046 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
12047 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
12048 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
12049 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
12050 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
12051 static_cast<unsigned char>(itr[10] -
'0') < 10 &&
12052 static_cast<unsigned char>(itr[11] -
'0') < 10;
12056 template <
typename Iterator>
12061 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
12062 static_cast<unsigned char>(itr[ 1] -
'0') < 10 &&
12063 static_cast<unsigned char>(itr[ 2] -
'0') < 10 &&
12064 static_cast<unsigned char>(itr[ 3] -
'0') < 10 &&
12065 static_cast<unsigned char>(itr[ 4] -
'0') < 10 &&
12066 static_cast<unsigned char>(itr[ 5] -
'0') < 10 &&
12067 static_cast<unsigned char>(itr[ 6] -
'0') < 10 &&
12068 static_cast<unsigned char>(itr[ 7] -
'0') < 10 &&
12069 static_cast<unsigned char>(itr[ 8] -
'0') < 10 &&
12070 static_cast<unsigned char>(itr[ 9] -
'0') < 10 &&
12071 static_cast<unsigned char>(itr[10] -
'0') < 10;
12075 template <
typename Iterator>
12080 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12081 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12082 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12083 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12084 static_cast<unsigned char>(itr[4] -
'0') < 10 &&
12085 static_cast<unsigned char>(itr[5] -
'0') < 10 &&
12086 static_cast<unsigned char>(itr[6] -
'0') < 10 &&
12087 static_cast<unsigned char>(itr[7] -
'0') < 10 &&
12088 static_cast<unsigned char>(itr[8] -
'0') < 10 &&
12089 static_cast<unsigned char>(itr[9] -
'0') < 10;
12093 template <
typename Iterator>
12098 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12099 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12100 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12101 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12102 static_cast<unsigned char>(itr[4] -
'0') < 10 &&
12103 static_cast<unsigned char>(itr[5] -
'0') < 10 &&
12104 static_cast<unsigned char>(itr[6] -
'0') < 10 &&
12105 static_cast<unsigned char>(itr[7] -
'0') < 10 &&
12106 static_cast<unsigned char>(itr[8] -
'0') < 10;
12110 template <
typename Iterator>
12115 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12116 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12117 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12118 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12119 static_cast<unsigned char>(itr[4] -
'0') < 10 &&
12120 static_cast<unsigned char>(itr[5] -
'0') < 10 &&
12121 static_cast<unsigned char>(itr[6] -
'0') < 10 &&
12122 static_cast<unsigned char>(itr[7] -
'0') < 10;
12126 template <
typename Iterator>
12131 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12132 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12133 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12134 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12135 static_cast<unsigned char>(itr[4] -
'0') < 10 &&
12136 static_cast<unsigned char>(itr[5] -
'0') < 10 &&
12137 static_cast<unsigned char>(itr[6] -
'0') < 10;
12141 template <
typename Iterator>
12146 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12147 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12148 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12149 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12150 static_cast<unsigned char>(itr[4] -
'0') < 10 &&
12151 static_cast<unsigned char>(itr[5] -
'0') < 10;
12155 template <
typename Iterator>
12160 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12161 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12162 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12163 static_cast<unsigned char>(itr[3] -
'0') < 10 &&
12164 static_cast<unsigned char>(itr[4] -
'0') < 10;
12168 template <
typename Iterator>
12173 return static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12174 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12175 static_cast<unsigned char>(itr[2] -
'0') < 10 &&
12176 static_cast<unsigned char>(itr[3] -
'0') < 10;
12180 template <
typename Iterator>
12186 static_cast<unsigned char>(itr[0] -
'0') < 10 &&
12187 static_cast<unsigned char>(itr[1] -
'0') < 10 &&
12188 static_cast<unsigned char>(itr[2] -
'0') < 10;
12192 template <
typename Iterator>
12197 return static_cast<unsigned char>(itr[ 0] -
'0') < 10 &&
12198 static_cast<unsigned char>(itr[ 1] -
'0') < 10;
12202 template <
typename Iterator>
12207 return static_cast<unsigned char>(itr[ 0] -
'0') < 10;
12211 template <
typename Iterator>
12220 template <
typename T,
typename Iterator,
int N>
12224 {
throw std::runtime_error(
"numeric_convert_impl::process( - unsupported value for N."); }
12227 template <
typename T,
typename Iterator>
12233 t +=
static_cast<T>((itr[0] -
'0') * 1000000000000000000LL);
12237 template <
typename T,
typename Iterator>
12243 t +=
static_cast<T>((itr[0] -
'0') * 100000000000000000LL);
12247 template <
typename T,
typename Iterator>
12253 t +=
static_cast<T>((itr[0] -
'0') * 10000000000000000LL);
12257 template <
typename T,
typename Iterator>
12262 T x =
static_cast<T>((itr[ 0] -
'0') * 1000000000000000LL);
12263 x +=
static_cast<T>((itr[ 1] -
'0') * 100000000000000LL);
12264 x +=
static_cast<T>((itr[ 2] -
'0') * 10000000000000LL);
12265 x +=
static_cast<T>((itr[ 3] -
'0') * 1000000000000LL);
12266 x +=
static_cast<T>((itr[ 4] -
'0') * 100000000000LL);
12267 x +=
static_cast<T>((itr[ 5] -
'0') * 10000000000LL);
12268 x +=
static_cast<T>((itr[ 6] -
'0') * 1000000000LL);
12269 x +=
static_cast<T>((itr[ 7] -
'0') * 100000000LL);
12270 x +=
static_cast<T>((itr[ 8] -
'0') * 10000000LL);
12271 x +=
static_cast<T>((itr[ 9] -
'0') * 1000000LL);
12272 x +=
static_cast<T>((itr[10] -
'0') * 100000LL);
12273 x +=
static_cast<T>((itr[11] -
'0') * 10000LL);
12274 x +=
static_cast<T>((itr[12] -
'0') * 1000LL);
12275 x +=
static_cast<T>((itr[13] -
'0') * 100LL);
12276 x +=
static_cast<T>((itr[14] -
'0') * 10LL);
12277 x +=
static_cast<T>((itr[15] -
'0') );
12282 template <
typename T,
typename Iterator>
12287 T x =
static_cast<T>((itr[ 0] -
'0') * 100000000000000LL);
12288 x +=
static_cast<T>((itr[ 1] -
'0') * 10000000000000LL);
12289 x +=
static_cast<T>((itr[ 2] -
'0') * 1000000000000LL);
12290 x +=
static_cast<T>((itr[ 3] -
'0') * 100000000000LL);
12291 x +=
static_cast<T>((itr[ 4] -
'0') * 10000000000LL);
12292 x +=
static_cast<T>((itr[ 5] -
'0') * 1000000000LL);
12293 x +=
static_cast<T>((itr[ 6] -
'0') * 100000000LL);
12294 x +=
static_cast<T>((itr[ 7] -
'0') * 10000000LL);
12295 x +=
static_cast<T>((itr[ 8] -
'0') * 1000000LL);
12296 x +=
static_cast<T>((itr[ 9] -
'0') * 100000LL);
12297 x +=
static_cast<T>((itr[10] -
'0') * 10000LL);
12298 x +=
static_cast<T>((itr[11] -
'0') * 1000LL);
12299 x +=
static_cast<T>((itr[12] -
'0') * 100LL);
12300 x +=
static_cast<T>((itr[13] -
'0') * 10LL);
12301 x +=
static_cast<T>((itr[14] -
'0') );
12306 template <
typename T,
typename Iterator>
12311 T x =
static_cast<T>((itr[ 0] -
'0') * 10000000000000LL);
12312 x +=
static_cast<T>((itr[ 1] -
'0') * 1000000000000LL);
12313 x +=
static_cast<T>((itr[ 2] -
'0') * 100000000000LL);
12314 x +=
static_cast<T>((itr[ 3] -
'0') * 10000000000LL);
12315 x +=
static_cast<T>((itr[ 4] -
'0') * 1000000000LL);
12316 x +=
static_cast<T>((itr[ 5] -
'0') * 100000000LL);
12317 x +=
static_cast<T>((itr[ 6] -
'0') * 10000000LL);
12318 x +=
static_cast<T>((itr[ 7] -
'0') * 1000000LL);
12319 x +=
static_cast<T>((itr[ 8] -
'0') * 100000LL);
12320 x +=
static_cast<T>((itr[ 9] -
'0') * 10000LL);
12321 x +=
static_cast<T>((itr[10] -
'0') * 1000LL);
12322 x +=
static_cast<T>((itr[11] -
'0') * 100LL);
12323 x +=
static_cast<T>((itr[12] -
'0') * 10LL);
12324 x +=
static_cast<T>((itr[13] -
'0') );
12329 template <
typename T,
typename Iterator>
12334 T x =
static_cast<T>((itr[ 0] -
'0') * 1000000000000LL);
12335 x +=
static_cast<T>((itr[ 1] -
'0') * 100000000000LL);
12336 x +=
static_cast<T>((itr[ 2] -
'0') * 10000000000LL);
12337 x +=
static_cast<T>((itr[ 3] -
'0') * 1000000000LL);
12338 x +=
static_cast<T>((itr[ 4] -
'0') * 100000000LL);
12339 x +=
static_cast<T>((itr[ 5] -
'0') * 10000000LL);
12340 x +=
static_cast<T>((itr[ 6] -
'0') * 1000000LL);
12341 x +=
static_cast<T>((itr[ 7] -
'0') * 100000LL);
12342 x +=
static_cast<T>((itr[ 8] -
'0') * 10000LL);
12343 x +=
static_cast<T>((itr[ 9] -
'0') * 1000LL);
12344 x +=
static_cast<T>((itr[10] -
'0') * 100LL);
12345 x +=
static_cast<T>((itr[11] -
'0') * 10LL);
12346 x +=
static_cast<T>((itr[12] -
'0') );
12351 template <
typename T,
typename Iterator>
12356 T x =
static_cast<T>((itr[ 0] -
'0') * 100000000000LL);
12357 x +=
static_cast<T>((itr[ 1] -
'0') * 10000000000LL);
12358 x +=
static_cast<T>((itr[ 2] -
'0') * 1000000000LL);
12359 x +=
static_cast<T>((itr[ 3] -
'0') * 100000000LL);
12360 x +=
static_cast<T>((itr[ 4] -
'0') * 10000000LL);
12361 x +=
static_cast<T>((itr[ 5] -
'0') * 1000000LL);
12362 x +=
static_cast<T>((itr[ 6] -
'0') * 100000LL);
12363 x +=
static_cast<T>((itr[ 7] -
'0') * 10000LL);
12364 x +=
static_cast<T>((itr[ 8] -
'0') * 1000LL);
12365 x +=
static_cast<T>((itr[ 9] -
'0') * 100LL);
12366 x +=
static_cast<T>((itr[10] -
'0') * 10LL);
12367 x +=
static_cast<T>((itr[11] -
'0') );
12372 template <
typename T,
typename Iterator>
12377 T x =
static_cast<T>((itr[ 0] -
'0') * 10000000000LL);
12378 x +=
static_cast<T>((itr[ 1] -
'0') * 1000000000LL);
12379 x +=
static_cast<T>((itr[ 2] -
'0') * 100000000LL);
12380 x +=
static_cast<T>((itr[ 3] -
'0') * 10000000LL);
12381 x +=
static_cast<T>((itr[ 4] -
'0') * 1000000LL);
12382 x +=
static_cast<T>((itr[ 5] -
'0') * 100000LL);
12383 x +=
static_cast<T>((itr[ 6] -
'0') * 10000LL);
12384 x +=
static_cast<T>((itr[ 7] -
'0') * 1000LL);
12385 x +=
static_cast<T>((itr[ 8] -
'0') * 100LL);
12386 x +=
static_cast<T>((itr[ 9] -
'0') * 10LL);
12387 x +=
static_cast<T>((itr[10] -
'0') );
12392 template <
typename T,
typename Iterator>
12397 T x =
static_cast<T>((itr[0] -
'0') * 1000000000);
12398 x +=
static_cast<T>((itr[1] -
'0') * 100000000);
12399 x +=
static_cast<T>((itr[2] -
'0') * 10000000);
12400 x +=
static_cast<T>((itr[3] -
'0') * 1000000);
12401 x +=
static_cast<T>((itr[4] -
'0') * 100000);
12402 x +=
static_cast<T>((itr[5] -
'0') * 10000);
12403 x +=
static_cast<T>((itr[6] -
'0') * 1000);
12404 x +=
static_cast<T>((itr[7] -
'0') * 100);
12405 x +=
static_cast<T>((itr[8] -
'0') * 10);
12406 x +=
static_cast<T>((itr[9] -
'0') );
12411 template <
typename T,
typename Iterator>
12416 T x =
static_cast<T>((itr[0] -
'0') * 100000000);
12417 x +=
static_cast<T>((itr[1] -
'0') * 10000000);
12418 x +=
static_cast<T>((itr[2] -
'0') * 1000000);
12419 x +=
static_cast<T>((itr[3] -
'0') * 100000);
12420 x +=
static_cast<T>((itr[4] -
'0') * 10000);
12421 x +=
static_cast<T>((itr[5] -
'0') * 1000);
12422 x +=
static_cast<T>((itr[6] -
'0') * 100);
12423 x +=
static_cast<T>((itr[7] -
'0') * 10);
12424 x +=
static_cast<T>((itr[8] -
'0') );
12429 template <
typename T,
typename Iterator>
12434 T x =
static_cast<T>((itr[0] -
'0') * 10000000);
12435 x +=
static_cast<T>((itr[1] -
'0') * 1000000);
12436 x +=
static_cast<T>((itr[2] -
'0') * 100000);
12437 x +=
static_cast<T>((itr[3] -
'0') * 10000);
12438 x +=
static_cast<T>((itr[4] -
'0') * 1000);
12439 x +=
static_cast<T>((itr[5] -
'0') * 100);
12440 x +=
static_cast<T>((itr[6] -
'0') * 10);
12441 x +=
static_cast<T>((itr[7] -
'0') );
12446 template <
typename T,
typename Iterator>
12451 T x =
static_cast<T>((itr[0] -
'0') * 1000000);
12452 x +=
static_cast<T>((itr[1] -
'0') * 100000);
12453 x +=
static_cast<T>((itr[2] -
'0') * 10000);
12454 x +=
static_cast<T>((itr[3] -
'0') * 1000);
12455 x +=
static_cast<T>((itr[4] -
'0') * 100);
12456 x +=
static_cast<T>((itr[5] -
'0') * 10);
12457 x +=
static_cast<T>((itr[6] -
'0') );
12462 template <
typename T,
typename Iterator>
12467 T x =
static_cast<T>((itr[0] -
'0') * 100000);
12468 x +=
static_cast<T>((itr[1] -
'0') * 10000);
12469 x +=
static_cast<T>((itr[2] -
'0') * 1000);
12470 x +=
static_cast<T>((itr[3] -
'0') * 100);
12471 x +=
static_cast<T>((itr[4] -
'0') * 10);
12472 x +=
static_cast<T>((itr[5] -
'0') );
12477 template <
typename T,
typename Iterator>
12482 T x =
static_cast<T>((itr[0] -
'0') * 10000);
12483 x +=
static_cast<T>((itr[1] -
'0') * 1000);
12484 x +=
static_cast<T>((itr[2] -
'0') * 100);
12485 x +=
static_cast<T>((itr[3] -
'0') * 10);
12486 x +=
static_cast<T>((itr[4] -
'0') );
12491 template <
typename T,
typename Iterator>
12496 T x =
static_cast<T>((itr[0] -
'0') * 1000);
12497 x +=
static_cast<T>((itr[1] -
'0') * 100);
12498 x +=
static_cast<T>((itr[2] -
'0') * 10);
12499 x +=
static_cast<T>((itr[3] -
'0') );
12504 template <
typename T,
typename Iterator>
12509 T x =
static_cast<T>((itr[0] -
'0') * 100);
12510 x +=
static_cast<T>((itr[1] -
'0') * 10);
12511 x +=
static_cast<T>((itr[2] -
'0') );
12516 template <
typename T,
typename Iterator>
12521 T x =
static_cast<T>((itr[0] -
'0') * 10);
12522 x +=
static_cast<T>((itr[1] -
'0') );
12527 template <
typename T,
typename Iterator>
12532 t =
static_cast<T>((itr[0] -
'0'));
12536 template <
typename T,
typename Iterator>
12545 template <
typename T,
typename NoneSignedTag>
12551 template <
typename T>
12560 template <
int N,
typename Iterator>
12567 template <
int N,
typename Iterator>
12570 return all_digits_check<N,const char*>(s.data());
12573 template <
typename Iterator>
12598 default :
return false;
12602 template <
typename Iterator>
12613 template <
int N,
typename Iterator>
12616 if ((
'-' == (*itr)) || (
'+' == (*itr)))
12619 return all_digits_check<Iterator,N>(itr);
12622 template <
typename Iterator>
12625 if ((
'-' == (*itr)) || (
'+' == (*itr)))
12634 return signed_all_digits_check<N,const char*>(s.data());
12637 template <
typename Iterator>
12648 template <
int N,
typename T,
typename Iterator>
12654 if (!all_digits_check<N,Iterator>(itr))
12664 template <
int N,
typename T>
12667 numeric_convert<N,T,const char*>(s.data(),t,digit_check);
12670 template <
typename T,
typename Iterator>
12672 Iterator itr,
T& t,
12673 const bool digit_check =
false)
12705 default :
return false;
12709 template <
typename T>
12715 template <
int N,
typename T,
typename Iterator>
12724 else if (
'+' == (*itr))
12729 numeric_convert<N,T,Iterator>(itr,t,digit_check);
12732 template <
typename T,
typename Iterator>
12736 const bool digit_check =
false)
12742 return details::negate<T>(t,
type) && result;
12744 else if (
'+' == (*itr))
12752 template <
int N,
typename T>
12755 const bool digit_check =
false)
12757 signed_numeric_convert<N,T,const char*>(s.data(),t,digit_check);
12760 template <
typename T>
12763 const bool digit_check =
false)
12765 return signed_numeric_convert<T,const char*>(s.size(),s.data(),t,digit_check);
12775 namespace details_endian
12777 #if (defined(__LITTLE_ENDIAN__)) ||\
12778 (defined(WIN32)) ||\
12779 (defined(__MINGW32_VERSION)) ||\
12780 (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
12781 static const bool __le_result =
true;
12782 static const bool __be_result =
false;
12784 static const bool __le_result =
false;
12785 static const bool __be_result =
true;
12789 static inline bool is_little_endian()
12792 return details_endian::__le_result;
12795 static inline bool is_big_endian()
12797 return details_endian::__be_result;
12800 static inline unsigned short convert(
const unsigned short v)
12803 return ((v >> 8) & 0x00FF) | ((v << 8) & 0xFFFF);
12806 static inline unsigned int convert(
const unsigned int v)
12809 return ((v >> 24) & 0x000000FF) | ((v << 24) & 0x0000FF00) |
12810 ((v << 8) & 0x00FF0000) | ((v >> 8) & 0xFF000000);
12813 static inline unsigned long long int convert(
const unsigned long long int v)
12816 return ((v >> 56) & 0x00000000000000FFLL) | ((v << 56) & 0xFF00000000000000LL) |
12817 ((v >> 40) & 0x000000000000FF00LL) | ((v << 40) & 0x00FF000000000000LL) |
12818 ((v >> 24) & 0x0000000000FF0000LL) | ((v << 24) & 0x0000FF0000000000LL) |
12819 ((v >> 8) & 0x00000000FF000000LL) | ((v << 8) & 0x000000FF00000000LL) ;
12822 static inline short convert(
const short v)
12824 return static_cast<short>(convert(static_cast<unsigned short>(v)));
12827 static inline int convert(
const int v)
12829 return static_cast<int>(convert(static_cast<unsigned int>(v)));
12832 static inline unsigned long long int convert(
const long long int v)
12834 return static_cast<long long>(convert(static_cast<unsigned long long int>(v)));
12837 static inline unsigned short convert_to_be(
const unsigned short v)
12839 if (is_little_endian()) convert(v);
12843 static inline unsigned int convert_to_be(
const unsigned int v)
12845 if (is_little_endian()) convert(v);
12849 static inline unsigned long long int convert_to_be(
const unsigned long long int v)
12851 if (is_little_endian()) convert(v);
12855 static inline short convert_to_be(
const short v)
12857 if (is_little_endian()) convert(v);
12861 static inline int convert_to_be(
const int v)
12863 if (is_little_endian()) convert(v);
12867 static inline unsigned long long int convert_to_be(
const long long int v)
12869 if (is_little_endian()) convert(v);
12873 static inline unsigned short convert_to_le(
const unsigned short v)
12875 if (is_big_endian()) convert(v);
12879 static inline unsigned int convert_to_le(
const unsigned int v)
12881 if (is_big_endian()) convert(v);
12885 static inline unsigned long long int convert_to_le(
const unsigned long long int v)
12887 if (is_big_endian()) convert(v);
12891 static inline short convert_to_le(
const short v)
12893 if (is_big_endian()) convert(v);
12897 static inline int convert_to_le(
const int v)
12899 if (is_big_endian()) convert(v);
12903 static inline unsigned long long int convert_to_le(
const long long int v)
12905 if (is_big_endian()) convert(v);
12913 typedef std::pair<std::size_t,char*> mark_type;
12917 inline bool reset(std::size_t& v1,
char*& v2)
12919 if (stack_.empty())
12921 v1 = stack_.top().first;
12922 v2 = stack_.top().second;
12927 inline void mark(
const std::size_t& v1,
char* v2)
12934 std::stack<mark_type> stack_;
12949 template <
typename T>
12951 const std::size_t& buffer_length)
12952 : original_buffer_(reinterpret_cast<char*>(buffer)),
12953 buffer_(reinterpret_cast<char*>(buffer)),
12954 buffer_length_(buffer_length * sizeof(
T)),
12955 amount_read_sofar_(0)
12960 return (0 == buffer_length_) ||
12961 (0 == original_buffer_) ||
12965 inline void reset(
const bool clear_buffer =
false)
12967 amount_read_sofar_ = 0;
12968 buffer_ = original_buffer_;
12975 return amount_read_sofar_;
12985 return amount_read_sofar_;
12990 if (n_bytes <= amount_read_sofar_)
12992 amount_read_sofar_ -= n_bytes;
12993 buffer_ -= n_bytes;
13003 return rewind(-n_bytes);
13004 else if (n_bytes > 0)
13006 if ((amount_read_sofar_ + n_bytes) <= buffer_length_)
13008 amount_read_sofar_ += n_bytes;
13009 buffer_ += n_bytes;
13022 std::memset(buffer_,0x00,buffer_length_);
13025 template <
typename T>
13028 if (read_length && !
operator()(length))
13031 const std::size_t raw_size = length *
sizeof(
T);
13032 if (!buffer_capacity_ok(raw_size))
13037 data =
new T[length];
13039 std::copy(buffer_, buffer_ + raw_size, reinterpret_cast<char*>(data));
13040 buffer_ += raw_size;
13041 amount_read_sofar_ += raw_size;
13045 template <
typename T>
13050 l =
static_cast<uint32_t>(length);
13051 if (!
operator()(data,l,read_length))
13061 if (!
operator()(length))
13064 if (!buffer_capacity_ok(length))
13067 output.resize(length);
13070 const_cast<char*>(output.data()));
13072 amount_read_sofar_ += length;
13076 template <
typename T1,
typename T2>
13079 if (!
operator()(p.first))
13081 if (!
operator()(p.second))
13086 template <
typename T,
13087 typename Allocator,
13088 template <
typename,
typename>
class Sequence>
13095 const std::size_t raw_size = size *
sizeof(
T);
13096 if (!buffer_capacity_ok(raw_size))
13101 for (std::size_t i = 0; i < size; ++i)
13111 template <
typename T,
typename Allocator>
13117 const std::size_t raw_size = size *
sizeof(
T);
13118 if (!buffer_capacity_ok(raw_size))
13121 return selector<T>::type::batch_vector_read(*
this,size,vec,
false);
13124 template <
typename T,
13125 typename Comparator,
13126 typename Allocator>
13133 const std::size_t raw_size = size *
sizeof(
T);
13134 if (!buffer_capacity_ok(raw_size))
13138 for (std::size_t i = 0; i < size; ++i)
13140 if (!
operator()(t))
13148 template <
typename T,
13149 typename Allocator,
13150 typename Comparator>
13151 inline bool operator()(std::multiset<T,Allocator,Comparator>& multiset)
13157 const std::size_t raw_size = size *
sizeof(
T);
13158 if (!buffer_capacity_ok(raw_size))
13162 for (std::size_t i = 0; i < size; ++i)
13164 if (!
operator()(t))
13166 multiset.insert(t);
13172 inline bool operator()(std::ifstream& stream,
const std::size_t& length)
13174 if (length > buffer_length_)
return false;
13175 stream.read(original_buffer_,static_cast<std::streamsize>(length));
13181 if (0 == amount_read_sofar_)
return false;
13182 stream.read(original_buffer_,static_cast<std::streamsize>(amount_read_sofar_));
13186 template <
typename T>
13189 return selector<T>::type::run(*
this,output);
13192 template <
typename T>
13195 return selector<T>::type::run(*
this,const_cast<T&>(output));
13198 template <
typename T>
13202 if (details::is_little_endian())
13204 if (!
operator()<
T>(output))
return false;
13205 output = details::convert(output);
13209 return operator()(output);
13212 template <
typename T>
13216 if (details::is_little_endian())
13217 return operator()(output);
13220 if (!
operator()<
T>(output))
return false;
13221 output = details::convert(output);
13226 template <
typename T, std::
size_t N>
13229 const std::size_t raw_size = N *
sizeof(
T);
13230 if (buffer_capacity_ok(raw_size))
13233 buffer_ + raw_size,
13234 reinterpret_cast<char*>(output));
13235 buffer_ += raw_size;
13236 amount_read_sofar_ += raw_size;
13243 template <
typename T>
13246 if (buffer_capacity_ok(size))
13248 bool result = strtk::string_to_type_converter<char*,T>(buffer_,buffer_ + size,output);
13250 amount_read_sofar_ += size;
13259 marker_.mark(amount_read_sofar_,buffer_);
13264 return marker_.reset(amount_read_sofar_,buffer_);
13273 inline bool buffer_capacity_ok(
const std::size_t& required_read_qty)
13275 return ((required_read_qty + amount_read_sofar_) <= buffer_length_);
13278 template <
typename Type>
13283 template <
typename T,
typename IsPOD>
13284 struct selector_impl
13286 template <
typename Reader>
13287 static inline bool run(Reader& r,
T& t)
13292 template <
typename Reader,
13293 typename Allocator>
13294 static inline bool batch_vector_read(Reader& r,
13295 const std::size_t& size,
13296 std::vector<T,Allocator>& v,
13300 for (std::size_t i = 0; i < size; ++i)
13302 if (r.operator()(t))
13311 template <
typename T>
13312 struct selector_impl<
T,strtk::details::yes_t>
13314 template <
typename Reader>
13315 static inline bool run(Reader& r,
13317 const bool perform_buffer_capacity_check =
true)
13319 return r.read_pod(t,perform_buffer_capacity_check);
13322 template <
typename Reader,
13323 typename Allocator>
13324 static inline bool batch_vector_read(Reader& r,
13325 const std::size_t& size,
13326 std::vector<T,Allocator>& v,
13329 const std::size_t raw_size =
sizeof(
T) * size;
13330 char*
ptr =
const_cast<char*
>(
reinterpret_cast<const char*
>(&v[0]));
13331 std::copy(r.buffer_, r.buffer_ + raw_size, ptr);
13332 r.buffer_ += raw_size;
13333 r.amount_read_sofar_ += raw_size;
13340 typedef selector_impl<Type,typename strtk::details::is_pod<Type>::result_t>
type;
13343 template <
typename T>
13344 inline bool read_pod(
T& data,
const bool perform_buffer_capacity_check =
true)
13346 static const std::size_t data_length =
sizeof(
T);
13347 if (perform_buffer_capacity_check)
13349 if (!buffer_capacity_ok(data_length))
13352 data = (*
reinterpret_cast<T*
>(buffer_));
13353 buffer_ += data_length;
13354 amount_read_sofar_ += data_length;
13358 char*
const original_buffer_;
13360 std::size_t buffer_length_;
13361 std::size_t amount_read_sofar_;
13362 details::marker marker_;
13376 template <
typename T>
13378 : original_buffer_(reinterpret_cast<char*>(buffer)),
13379 buffer_(reinterpret_cast<char*>(buffer)),
13380 buffer_length_(buffer_length * sizeof(
T)),
13381 amount_written_sofar_(0)
13386 return (0 == buffer_length_) ||
13387 (0 == original_buffer_) ||
13391 inline void reset(
const bool clear_buffer =
false)
13393 amount_written_sofar_ = 0;
13394 buffer_ = original_buffer_;
13401 return amount_written_sofar_;
13411 return amount_written_sofar_;
13417 std::memset(buffer_,0x00,buffer_length_);
13420 template <
typename T, std::
size_t N>
13421 inline bool operator()(
const T (&data)[N],
const bool write_length =
false)
13423 if (write_length && !
operator()(N))
13426 const std::size_t raw_size = N *
sizeof(
T);
13427 if (!buffer_capacity_ok(raw_size))
13430 const char*
ptr =
reinterpret_cast<const char*
>(data);
13431 std::copy(ptr, ptr + raw_size, buffer_);
13432 buffer_ += raw_size;
13433 amount_written_sofar_ += raw_size;
13437 template <
typename T>
13440 if (write_length && !
operator()(length))
13443 const std::size_t raw_size = length *
sizeof(
T);
13444 if (!buffer_capacity_ok(raw_size))
13447 const char*
ptr =
reinterpret_cast<const char*
>(data);
13448 std::copy(ptr, ptr + raw_size, buffer_);
13449 buffer_ += raw_size;
13450 amount_written_sofar_ += raw_size;
13454 template <
typename T>
13457 return operator()(data,static_cast<uint32_t>(length),write_length);
13460 template <
typename T>
13463 return operator()(data,static_cast<uint32_t>(length),write_length);
13466 template <
typename T>
13469 return operator()(data,static_cast<uint32_t>(length),write_length);
13472 template <
typename T1,
typename T2>
13475 if (!
operator()(p.first))
13477 if (!
operator()(p.second))
13484 return operator()<
const char>(input.data(),
static_cast<uint32_t>(input.size()));
13487 template <
typename T,
13488 typename Allocator,
13489 template <
typename,
typename>
class Sequence>
13493 if (!
operator()(size))
13496 typename Sequence<T,Allocator>::const_iterator itr = seq.begin();
13497 typename Sequence<T,Allocator>::const_iterator end = seq.end();
13500 if (!
operator()(*itr))
13507 template <
typename T,
13508 typename Allocator>
13512 const std::size_t raw_size = (size *
sizeof(
T));
13513 if (!buffer_capacity_ok(raw_size +
sizeof(size)))
13515 if (!
operator()(size))
13517 return selector<T>::type::batch_vector_writer(*
this,raw_size,vec);
13520 template <
typename T,
13521 typename Comparator,
13522 typename Allocator>
13526 if (!
operator()(size))
13529 const std::size_t raw_size = size *
sizeof(
T);
13530 if (!buffer_capacity_ok(raw_size))
13533 typename std::set<T,Comparator,Allocator>::const_iterator itr = set.begin();
13534 typename std::set<T,Comparator,Allocator>::const_iterator end = set.end();
13537 if (!
operator()(*itr))
13544 template <
typename T,
13545 typename Allocator,
13546 typename Comparator>
13547 inline bool operator()(
const std::multiset<T,Allocator,Comparator>& multiset)
13550 if (!
operator()(size))
13553 const std::size_t raw_size = size *
sizeof(
T);
13554 if (!buffer_capacity_ok(raw_size))
13557 typename std::multiset<T,Allocator,Comparator>::const_iterator itr = multiset.begin();
13558 typename std::multiset<T,Allocator,Comparator>::const_iterator end = multiset.end();
13561 if (!
operator()(*itr))
13570 stream.write(original_buffer_,static_cast<std::streamsize>(amount_written_sofar_));
13571 return amount_written_sofar_;
13574 template <
typename T>
13577 return selector<T>::type::run(*
this,input);
13580 template <
typename T>
13584 if (details::is_little_endian())
13586 return operator()<
T>(details::convert(input));
13589 return operator()<
T>(input);
13592 template <
typename T>
13596 if (details::is_little_endian())
13597 return operator()<
T>(input);
13599 return operator()<
T>(details::convert(input));
13608 template <
typename T>
13610 const std::size_t& size,
13612 const char padding =
' ')
13614 if (amount_written_sofar_ + size <= buffer_length_)
13618 if (!strtk::type_to_string<T>(input,s))
13620 else if (s.size() > size)
13622 else if (s.size() < size)
13624 if (right_padding == pmode)
13625 s.resize(size - s.size(),padding);
13629 return operator()<
const char>(s.data(),
static_cast<uint32_t>(size),
false);
13637 marker_.mark(amount_written_sofar_,buffer_);
13642 return marker_.reset(amount_written_sofar_,buffer_);
13651 inline bool buffer_capacity_ok(
const std::size_t& required_write_qty)
13653 return ((required_write_qty + amount_written_sofar_) <= buffer_length_);
13656 template <
typename Type>
13661 template <
typename T,
typename IsPOD>
13662 struct selector_impl
13664 template <
typename Writer>
13665 static inline bool run(Writer& w,
const T& t)
13670 template <
typename Writer,
13671 typename Allocator>
13672 static inline bool batch_vector_writer(Writer& w,
13673 const std::size_t&,
13674 const std::vector<T,Allocator>& v)
13676 for (std::size_t i = 0; i < v.size(); ++i)
13678 if (w.operator()(v[i]))
13687 template <
typename T>
13688 struct selector_impl<
T,strtk::details::yes_t>
13690 template <
typename Writer>
13691 static inline bool run(Writer& w,
const T& t)
13693 return w.write_pod(t);
13696 template <
typename Writer,
13697 typename Allocator>
13698 static inline bool batch_vector_writer(Writer& w,
13699 const std::size_t& raw_size,
13700 const std::vector<T,Allocator>& v)
13702 const char*
ptr =
reinterpret_cast<const char*
>(&v[0]);
13703 std::copy(ptr, ptr + raw_size, w.buffer_);
13704 w.buffer_ += raw_size;
13705 w.amount_written_sofar_ += raw_size;
13712 typedef selector_impl<Type,typename strtk::details::is_pod<Type>::result_t>
type;
13715 template <
typename T>
13716 inline bool write_pod(
const T& data,
const bool perform_buffer_capacity_check =
true)
13718 static const std::size_t data_length =
sizeof(
T);
13719 if (perform_buffer_capacity_check)
13721 if ((data_length + amount_written_sofar_) > buffer_length_)
13726 *(
reinterpret_cast<T*
>(buffer_)) = data;
13727 buffer_ += data_length;
13728 amount_written_sofar_ += data_length;
13732 char*
const original_buffer_;
13734 std::size_t buffer_length_;
13735 std::size_t amount_written_sofar_;
13736 details::marker marker_;
13739 #define strtk_binary_reader_begin()\
13740 bool operator()(strtk::binary::reader& reader)\
13743 #define strtk_binary_reader(T)\
13746 #define strtk_binary_reader_end()\
13749 #define strtk_binary_writer_begin()\
13750 bool operator()(strtk::binary::writer& writer) const\
13753 #define strtk_binary_writer(T)\
13756 #define strtk_binary_writer_end()\
13761 template <
typename size_type>
13789 size_type size = 0;
13793 char*
ptr =
const_cast<char*
>(s->data());
13795 if (!r(ptr,length,
false))
13804 if (s->size() > std::numeric_limits<size_type>::max())
13806 const size_type size =
static_cast<size_type
>(s->size());
13809 if (!w(s->data(),size,
false))
13830 template <
typename InputIterator>
13842 template <
typename T>
13848 struct hex_value_check
13850 inline bool operator()(
const unsigned char c)
const
13852 return ((
'0' <= c) && (c <=
'9')) ||
13853 ((
'A' <= c) && (c <=
'F')) ||
13854 ((
'a' <= c) && (c <=
'f'));
13857 inline bool operator()(
const char c)
const
13859 return (*
this)(
static_cast<unsigned char>(c));
13871 : valid_(hns.valid),
13877 valid_ = hns.valid_;
13882 template <
typename InputIterator>
13885 std::size_t offset = 0;
13887 if ((size > 2) && ((*s.first) ==
'0') && (((*(s.first + 1)) ==
'x') || ((*(s.first + 1)) ==
'X')))
13889 if ((size - offset) > (2 *
sizeof(
T)))
13892 const std::size_t buffer_size = 2 *
sizeof(
T);
13893 const std::size_t buffer_offset = ((size - offset) % 2);
13894 char buffer[buffer_size] = {
'0' };
13901 std::copy(s.first + offset, s.first + size, buffer + buffer_offset);
13904 buffer + (size - offset) + buffer_offset,
13905 reinterpret_cast<char*>(t_));
13912 return this->operator =(
std::make_pair(s.data(),s.data() + s.size()));
13922 inline void reverse_bytes()
13924 unsigned char* itr1 =
reinterpret_cast<unsigned char*
>(t_);
13925 unsigned char* itr2 = itr1 + (
sizeof(
T) - 1);
13926 while (itr1 < itr2)
13940 template <
typename T>
13946 struct base64_value_check
13948 inline bool operator()(
const unsigned char c)
const
13950 return ((
'0' <= c) && (c <=
'9')) ||
13951 ((
'A' <= c) && (c <=
'Z')) ||
13952 ((
'a' <= c) && (c <=
'z')) ||
13958 inline bool operator()(
const char c)
const
13960 return (*
this)(
static_cast<unsigned char>(c));
13972 : valid_(bns.valid),
13978 valid_ = bns.valid_;
13993 s.data() + s.size(),
13994 reinterpret_cast<char*
>(t_));
13999 template <
typename InputIterator>
14021 inline void reverse_bytes()
14023 unsigned char* itr1 =
reinterpret_cast<unsigned char*
>(t_);
14024 unsigned char* itr2 = itr1 + (
sizeof(
T) - 1);
14025 while (itr1 < itr2)
14049 : valid_(hss.valid_),
14055 valid_ = hss.valid_;
14060 template <
typename InputIterator>
14064 std::size_t offset = 0;
14065 if ((size > 2) && ((*s.first) ==
'0') && (((*(s.first + 1)) ==
'x') || ((*(s.first + 1)) ==
'X')))
14067 if ((size - offset) < 2)
14072 s_.resize((size - offset) / 2);
14075 const_cast<char*>(s_.data()));
14081 return this->operator=(std::make_pair<char*>(const_cast<char*>(s.data()),
14082 const_cast<char*>(s.data() + s.size())));
14099 template <
typename InputIterator,
14101 typename Allocator,
14102 template <
typename,
typename>
class Sequence>
14104 const InputIterator end,
14106 Sequence<T,Allocator>& sequence,
14109 return parse(begin,end,delimiters,sequence,split_option);
14112 template <
typename InputIterator,
14114 typename Comparator,
14115 typename Allocator>
14117 const InputIterator end,
14119 std::set<T,Comparator,Allocator>& set,
14122 return parse(begin,end,delimiters,set,split_option);
14125 template <
typename InputIterator,
14127 typename Comparator,
14128 typename Allocator>
14130 const InputIterator end,
14132 std::multiset<T,Comparator,Allocator>& multiset,
14135 return parse(begin,end,delimiters,multiset,split_option);
14138 template <
typename InputIterator,
14140 typename Container>
14142 const InputIterator end,
14144 std::queue<T,Container>& queue,
14147 return parse(begin,end,delimiters,queue,split_option);
14150 template <
typename InputIterator,
14152 typename Container>
14154 const InputIterator end,
14156 std::stack<T,Container>& stack,
14159 return parse(begin,end,delimiters,stack,split_option);
14162 template <
typename InputIterator,
14164 typename Container,
14165 typename Comparator>
14167 const InputIterator end,
14169 std::priority_queue<T,Container,Comparator>& priority_queue,
14172 return parse(begin,end,delimiters,priority_queue,split_option);
14175 template <
typename InputIterator,
14177 typename Allocator,
14178 template <
typename,
typename>
class Sequence>
14180 const InputIterator end,
14182 const std::size_t& n,
14183 Sequence<T,Allocator>& sequence,
14186 return parse_n(begin,end,delimiters,n,sequence,split_option);
14189 template <
typename InputIterator,
14191 typename Comparator,
14192 typename Allocator>
14194 const InputIterator end,
14196 const std::size_t& n,
14197 std::set<T,Comparator,Allocator>& set,
14200 return parse_n(begin,end,delimiters,n,set,split_option);
14203 template <
typename InputIterator,
14205 typename Comparator,
14206 typename Allocator>
14208 const InputIterator end,
14210 const std::size_t& n,
14211 std::multiset<T,Comparator,Allocator>& multiset,
14214 return parse_n(begin,end,delimiters,n,multiset,split_option);
14217 template <
typename InputIterator,
14219 typename Container>
14221 const InputIterator end,
14223 const std::size_t& n,
14224 std::queue<T,Container>& queue,
14227 return parse_n(begin,end,delimiters,n,queue,split_option);
14230 template <
typename InputIterator,
14232 typename Container>
14234 const InputIterator end,
14236 const std::size_t& n,
14237 std::stack<T,Container>& stack,
14240 return parse_n(begin,end,delimiters,n,stack,split_option);
14243 template <
typename InputIterator,
14245 typename Container,
14246 typename Comparator>
14248 const InputIterator end,
14250 const std::size_t& n,
14251 std::priority_queue<T,Container,Comparator>& priority_queue,
14254 return parse_n(begin,end,delimiters,n,priority_queue,split_option);
14259 template <
typename Container>
14268 : delimiters_(delimiters),
14269 split_option_(split_option),
14271 element_count_(std::numeric_limits<std::size_t>::max())
14277 : delimiters_(delimiters),
14278 split_option_(split_option),
14279 container_(&container)
14282 inline sink_type&
count(
const std::size_t& element_count = std::numeric_limits<std::size_t>::max())
14284 element_count_ = element_count;
14292 container_ = (&container);
14293 if (!delimiters.empty())
14294 delimiters_ = delimiters;
14295 split_option_ = split_option;
14299 template <
typename InputIterator>
14300 inline bool parse(InputIterator begin, InputIterator end)
14304 if (std::numeric_limits<std::size_t>::max() == element_count_)
14306 (begin,end,delimiters_,(*container_),split_option_) > 0);
14309 (begin,end,delimiters_,element_count_,(*container_),split_option_) == element_count_);
14324 Container* container_;
14325 std::size_t element_count_;
14340 const std::string::value_type& pad,
14343 if (str.size() >= width)
return str;
14344 const std::size_t pad_count = width - str.size();
14345 const std::size_t pad_count_2 = (pad_count >> 1) + (pad_count & 1);
14350 const std::string::value_type& pad,
14353 if (str.size() >= width)
return str;
14354 return std::string(width - str.size(),pad) + str;
14358 const std::string::value_type& pad,
14361 if (str.size() >= width)
return str;
14362 return str +
std::string(width - str.size(),pad);
14365 template <
typename T>
14367 const std::string::value_type& pad,
14373 template <
typename T>
14375 const std::string::value_type& pad,
14381 template <
typename T>
14383 const std::string::value_type& pad,
14389 template <
typename T>
14395 template <
typename T>
14401 template <
typename T>
14410 return (index < str.size()) ? str.substr(index,str.size() - index) : str;
14417 result = (index < str.size()) ? str.substr(index,str.size() - index) : str;
14422 return ((
'A' <= c) && ( c <=
'Z')) || ((
'a' <= c) && ( c <=
'z'));
14427 return ((
'a' <= c) && ( c <=
'z'));
14432 return ((
'A' <= c) && ( c <=
'Z'));
14437 return ((
'0' <= c) && ( c <=
'9'));
14442 return ((
'0' <= c) && (c <=
'9')) ||
14443 ((
'A' <= c) && (c <=
'F')) ||
14444 ((
'a' <= c) && (c <=
'f'));
14454 for (std::size_t i = 0; i < s.size(); ++i)
14464 for (std::size_t i = 0; i < s.size(); ++i)
14474 if (i0 >= s.size())
return;
14475 if (i1 >= s.size())
return;
14488 if (index >= s.size())
14490 std::memcpy(const_cast<char*>(s.data() + index), const_cast<char*>(s.data() + (index + 1)), s.size() - index);
14491 s.resize(s.size() - 1);
14503 s.resize(s.size() + 1);
14504 std::memcpy(const_cast<char*>(s.data() + index + 1), const_cast<char*>(s.data() + (index)), s.size() - index);
14517 namespace find_mode
14526 namespace find_type
14541 template <
typename Iterator>
14544 typedef typename std::pair<Iterator,Iterator>
type;
14547 template <
typename Iterator,
typename Predicate>
14551 const Iterator end,
14552 const bool stateful_predicate =
false)
14556 std::size_t count = n;
14565 std::advance(itr,1 - n);
14572 while ((end != itr) && !p(*itr))
14574 if (!stateful_predicate)
14586 template <
typename Iterator,
typename Predicate>
14590 const Iterator end)
14594 std::size_t count = 0;
14606 std::advance(itr,-static_cast<int>(count));
14609 while ((end != itr) && !p(*itr))
14616 std::advance(itr,-static_cast<int>(count));
14623 template <
typename Iterator,
typename Predicate>
14627 const bool stateful_predicate =
false)
14632 template <
typename Iterator,
typename Predicate>
14640 template <
typename Iterator,
typename Predicate>
14645 const Iterator end)
14655 template <
typename Iterator,
typename Predicate>
14659 const Iterator end)
14663 std::size_t count = n;
14679 template <
typename Iterator,
typename Predicate>
14683 const Iterator end)
14687 std::size_t count = 0;
14695 else if (count >= n)
14703 template <
typename Iterator,
typename Predicate>
14708 const Iterator end)
14714 default :
return false;
14720 template <
typename Iterator>
14728 case find_type::digits :
return details::find_n_consecutive_values<Iterator>(n,
14731 range.first,range.second);
14736 range.first,range.second);
14741 range.first,range.second);
14746 range.first,range.second);
14751 range.first,range.second);
14757 template <
typename Iterator>
14765 case find_type::digits :
return details::match_n_consecutive_values<Iterator>(n,
14768 range.first,range.second);
14773 range.first,range.second);
14778 range.first,range.second);
14783 range.first,range.second);
14788 range.first,range.second);
14790 default :
return false;
14794 template <
typename Predicate,
14795 typename OutputIterator>
14800 OutputIterator out,
14801 const bool stateful_predicate =
false)
14803 if (0 == n)
return 0;
14806 range_type itr_range(begin,end);
14807 std::size_t match_count = 0;
14808 while (end != itr_range.first)
14810 range_type found_itr =
14811 details::find_exactly_n_consecutive_values<iterator_type,Predicate>(n,
14814 stateful_predicate);
14816 if ((end == found_itr.first) && (found_itr.first == found_itr.second))
14822 (*out) = found_itr;
14825 itr_range.first = found_itr.second;
14828 return match_count;
14831 template <
typename Predicate,
14832 typename OutputIterator>
14834 const std::size_t m,
14838 OutputIterator out)
14840 if (0 == n)
return 0;
14843 range_type itr_range(begin,end);
14844 std::size_t match_count = 0;
14845 while ((end != itr_range.first) && (match_count <= n))
14848 if ((end == found_itr.first) && (found_itr.first == found_itr.second))
14854 (*out) = found_itr;
14857 itr_range.first = found_itr.second;
14860 return match_count;
14863 template <
typename InputIterator,
typename OutputIterator>
14869 OutputIterator out)
14871 if (0 == n)
return 0;
14874 range_type itr_range(begin,end);
14875 std::size_t match_count = 0;
14876 while (end != itr_range.first)
14878 range_type found_itr = find_n_consecutive<iterator_type>(n,
type,mode,itr_range);
14879 if ((end == found_itr.first) && (found_itr.first == found_itr.second))
14885 (*out) = found_itr;
14888 itr_range.first = found_itr.second;
14891 return match_count;
14894 template <
typename InputIterator,
typename OutputIterator>
14896 const std::size_t& m,
14901 OutputIterator out)
14903 if (0 == n)
return 0;
14906 range_type itr_range(begin,end);
14907 std::size_t match_count = 0;
14908 while ((end != itr_range.first) && (match_count <= n))
14910 range_type found_itr = find_n_consecutive<iterator_type>(m,
type,mode,itr_range);
14911 if ((end == found_itr.first) && (found_itr.first == found_itr.second))
14917 (*out) = found_itr;
14920 itr_range.first = found_itr.second;
14923 return match_count;
14926 template <
typename OutputIterator>
14932 OutputIterator out)
14934 return split_on_consecutive<char*,OutputIterator>(n,
14937 const_cast<char*
>(begin),
14938 const_cast<char*>(end),
14942 template <
typename OutputIterator>
14946 const unsigned char* begin,
14947 const unsigned char* end,
14948 OutputIterator out)
14950 return split_on_consecutive<OutputIterator>(n,
14953 reinterpret_cast<const char*
>(begin),
14954 reinterpret_cast<const char*>(end),
14958 template <
typename OutputIterator>
14963 OutputIterator out)
14965 return split_on_consecutive<OutputIterator>(n,
14969 str.data() + str.size(),
14973 template <
typename OutputIterator>
14975 const std::size_t& m,
14980 OutputIterator out)
14982 return split_on_consecutive_n<char*,OutputIterator>(n,
14986 const_cast<char*
>(begin),
14987 const_cast<char*>(end),
14991 template <
typename OutputIterator>
14993 const std::size_t& m,
14996 const unsigned char* begin,
14997 const unsigned char* end,
14998 OutputIterator out)
15000 return split_on_consecutive_n<OutputIterator>(n,
15004 reinterpret_cast<const char*
>(begin),
15005 reinterpret_cast<const char*>(end),
15009 template <
typename OutputIterator>
15011 const std::size_t& m,
15015 OutputIterator out)
15017 return split_on_consecutive_n<OutputIterator>(n,
15022 str.data() + str.size(),
15026 template <
typename Predicate,
typename OutputIterator>
15031 OutputIterator out,
15032 const bool stateful_predicate =
false)
15037 const_cast<char*
>(begin),
15038 const_cast<char*>(end),
15040 stateful_predicate);
15043 template <
typename Predicate,
typename OutputIterator>
15046 const unsigned char* begin,
15047 const unsigned char* end,
15048 OutputIterator out,
15049 const bool stateful_predicate =
false)
15054 reinterpret_cast<const char*
>(begin),
15055 reinterpret_cast<const char*>(end),
15057 stateful_predicate);
15060 template <
typename Predicate,
typename OutputIterator>
15064 OutputIterator out,
15065 const bool stateful_predicate =
false)
15071 str.data() + str.size(),
15073 stateful_predicate);
15076 template <
typename Predicate,
typename OutputIterator>
15078 const std::size_t& m,
15082 OutputIterator out)
15089 const_cast<char*
>(begin),
15090 const_cast<char*>(end),
15094 template <
typename Predicate,
typename OutputIterator>
15096 const std::size_t& m,
15098 const unsigned char* begin,
15099 const unsigned char* end,
15100 OutputIterator out)
15106 reinterpret_cast<const char*
>(begin),
15107 reinterpret_cast<const char*>(end),
15111 template <
typename Predicate,
typename OutputIterator>
15113 const std::size_t& m,
15116 OutputIterator out)
15123 str.data() + str.size(),
15128 namespace util {
class value; }
15141 template <
typename InputIterator>
15144 if (static_cast<std::size_t>(
std::distance(begin,end)) != s_.size())
15147 return std::equal(s_.data(),s_.data() + s_.size(),begin);
15173 template <
typename InputIterator>
15176 if (static_cast<std::size_t>(
std::distance(begin,end)) != s_.size())
15179 return std::equal(s_.data(),s_.data() + s_.size(),begin,
imatch_char);
15205 template <
typename InputIterator>
15208 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
15209 static const value_type zero_or_more = value_type(
'*');
15210 static const value_type zero_or_one = value_type(
'?');
15211 return strtk::match(s_.data(),s_.data() + s_.size(),begin,end,zero_or_more,zero_or_one);
15229 template <
typename T>
15240 template <
typename InputIterator>
15246 else if (temp < low_)
15248 else if (temp > hi_)
15272 namespace trim_details
15274 template <
typename Type>
15277 template <
typename InputIterator>
15278 static bool execute(InputIterator begin, InputIterator end,
15291 default :
return false;
15300 template <
typename InputIterator>
15301 static bool execute(InputIterator begin, InputIterator end,
15313 default :
return false;
15320 template <
typename T>
15330 rem_chars_(rem_chars)
15333 template <
typename InputIterator>
15359 template <
typename InputIterator>
15363 s.assign(begin,end);
15386 template <
typename InputIterator>
15390 s.assign(begin,end);
15414 template <
typename InputIterator>
15417 const std::size_t range_size =
static_cast<std::size_t
>(
std::distance(begin,end));
15418 if (range_size != size_)
15420 std::memcpy(data_,begin,range_size);
15438 data_ =
reinterpret_cast<unsigned char*
>(data);
15451 data_ =
reinterpret_cast<unsigned char*
>(data);
15463 unsigned char* data_;
15484 template <
typename T,
typename T0,
typename T1>
15490 template <
typename T>
15496 template <
typename T>
15502 template <
typename T>
15528 template <std::
size_t N>
15534 template <std::
size_t N>
15542 return fill_array(const_cast<char*>(data.data()),size);
15547 return fill_array(const_cast<char*>(data.data()),data.size());
15552 static const unsigned char digit_table[] =
15554 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15555 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15556 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15557 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15558 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15559 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15560 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15561 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15562 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15563 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15564 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15565 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15566 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15567 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15568 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15569 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15570 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15571 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15572 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15573 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15574 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15575 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15576 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15577 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15578 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15579 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15580 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15581 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15582 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15583 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15584 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
15585 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
15588 static const std::size_t digit_table_size =
sizeof(digit_table) /
sizeof(
unsigned char);
15590 template <
typename T>
15591 static inline bool is_invalid_digit(
const T& t)
15593 static const unsigned int invalid_digit = 0xFF;
15594 return (static_cast<T>(invalid_digit) == t);
15597 template <
typename T>
15598 static inline bool is_valid_digit(
const T& t)
15600 static const unsigned int invalid_digit = 0xFF;
15601 return (static_cast<T>(invalid_digit) != t);
15604 static const unsigned char digitr[] =
15606 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
15609 static const unsigned char rev_3digit_lut[] =
15611 "000100200300400500600700800900010110210310410510610710810910020120220320420"
15612 "520620720820920030130230330430530630730830930040140240340440540640740840940"
15613 "050150250350450550650750850950060160260360460560660760860960070170270370470"
15614 "570670770870970080180280380480580680780880980090190290390490590690790890990"
15615 "001101201301401501601701801901011111211311411511611711811911021121221321421"
15616 "521621721821921031131231331431531631731831931041141241341441541641741841941"
15617 "051151251351451551651751851951061161261361461561661761861961071171271371471"
15618 "571671771871971081181281381481581681781881981091191291391491591691791891991"
15619 "002102202302402502602702802902012112212312412512612712812912022122222322422"
15620 "522622722822922032132232332432532632732832932042142242342442542642742842942"
15621 "052152252352452552652752852952062162262362462562662762862962072172272372472"
15622 "572672772872972082182282382482582682782882982092192292392492592692792892992"
15623 "003103203303403503603703803903013113213313413513613713813913023123223323423"
15624 "523623723823923033133233333433533633733833933043143243343443543643743843943"
15625 "053153253353453553653753853953063163263363463563663763863963073173273373473"
15626 "573673773873973083183283383483583683783883983093193293393493593693793893993"
15627 "004104204304404504604704804904014114214314414514614714814914024124224324424"
15628 "524624724824924034134234334434534634734834934044144244344444544644744844944"
15629 "054154254354454554654754854954064164264364464564664764864964074174274374474"
15630 "574674774874974084184284384484584684784884984094194294394494594694794894994"
15631 "005105205305405505605705805905015115215315415515615715815915025125225325425"
15632 "525625725825925035135235335435535635735835935045145245345445545645745845945"
15633 "055155255355455555655755855955065165265365465565665765865965075175275375475"
15634 "575675775875975085185285385485585685785885985095195295395495595695795895995"
15635 "006106206306406506606706806906016116216316416516616716816916026126226326426"
15636 "526626726826926036136236336436536636736836936046146246346446546646746846946"
15637 "056156256356456556656756856956066166266366466566666766866966076176276376476"
15638 "576676776876976086186286386486586686786886986096196296396496596696796896996"
15639 "007107207307407507607707807907017117217317417517617717817917027127227327427"
15640 "527627727827927037137237337437537637737837937047147247347447547647747847947"
15641 "057157257357457557657757857957067167267367467567667767867967077177277377477"
15642 "577677777877977087187287387487587687787887987097197297397497597697797897997"
15643 "008108208308408508608708808908018118218318418518618718818918028128228328428"
15644 "528628728828928038138238338438538638738838938048148248348448548648748848948"
15645 "058158258358458558658758858958068168268368468568668768868968078178278378478"
15646 "578678778878978088188288388488588688788888988098198298398498598698798898998"
15647 "009109209309409509609709809909019119219319419519619719819919029129229329429"
15648 "529629729829929039139239339439539639739839939049149249349449549649749849949"
15649 "059159259359459559659759859959069169269369469569669769869969079179279379479"
15650 "579679779879979089189289389489589689789889989099199299399499599699799899999"
15653 static const unsigned char rev_2digit_lut[] =
15655 "0010203040506070809001112131415161718191"
15656 "0212223242526272829203132333435363738393"
15657 "0414243444546474849405152535455565758595"
15658 "0616263646566676869607172737475767778797"
15659 "0818283848586878889809192939495969798999"
15662 #define strtk_register_pod_type(T)\
15663 template<> struct is_pod<T>{ typedef yes_t result_t; enum {result = true }; };\
15664 template<> struct is_pod<const T>{ typedef yes_t result_t; enum {result = true }; };\
15665 template<> struct is_pod<volatile T>{ typedef yes_t result_t; enum {result = true }; };\
15666 template<> struct is_pod<const volatile T>{ typedef yes_t result_t; enum {result = true }; };\
15684 #undef strtk_register_pod_type
15686 template <
typename>
15687 struct numeric {
enum { length = 0, size = 32, bound_length = 0, min_exp = 0, max_exp = 0 }; };
15689 template<>
struct numeric<short> {
enum { length = 5, size = 16, bound_length = 4}; };
15690 template<>
struct numeric<unsigned short> {
enum { length = 5, size = 16, bound_length = 4}; };
15692 template<>
struct numeric<int> {
enum { length = 10, size = 16, bound_length = 9}; };
15693 template<>
struct numeric<unsigned int> {
enum { length = 10, size = 16, bound_length = 9}; };
15695 template<>
struct numeric<long> {
enum { length = 10, size = 16, bound_length = 9}; };
15696 template<>
struct numeric<unsigned long> {
enum { length = 10, size = 16, bound_length = 9}; };
15698 template<>
struct numeric<long long> {
enum { length = 19, size = 24, bound_length = 18}; };
15699 template<>
struct numeric<unsigned long long int> {
enum { length = 20, size = 24, bound_length = 19}; };
15701 template<>
struct numeric<float> {
enum { min_exp = -38, max_exp = +38, precision = 10}; };
15702 template<>
struct numeric<double> {
enum { min_exp = -308, max_exp = +308, precision = 15}; };
15703 template<>
struct numeric<long double> {
enum { min_exp = -308, max_exp = +308, precision = 15}; };
15705 #define strtk_register_unsigned_type_tag(T)\
15706 template<> struct supported_conversion_to_type<T> { typedef unsigned_type_tag type; };\
15707 template<> struct supported_conversion_from_type<T> { typedef unsigned_type_tag type; };
15709 #define strtk_register_signed_type_tag(T)\
15710 template<> struct supported_conversion_to_type<T>{ typedef signed_type_tag type; };\
15711 template<> struct supported_conversion_from_type<T> { typedef signed_type_tag type; };
15713 #define strtk_register_real_type_tag(T)\
15714 template<> struct supported_conversion_to_type<T>{ typedef real_type_tag type; };
15716 #define strtk_register_byte_type_tag(T)\
15717 template<> struct supported_conversion_to_type<T>{ typedef byte_type_tag type; };\
15718 template<> struct supported_conversion_from_type<T> { typedef byte_type_tag type; };
15720 #define strtk_register_hex_number_type_tag(T)\
15721 template<> struct supported_conversion_to_type<T >{ typedef hex_number_type_tag type; };
15725 #define strtk_register_base64_type_tag(T)\
15726 template<> struct supported_conversion_to_type<T >{ typedef base64_type_tag type; };
15728 #define strtk_register_supported_iterator_type(T)\
15729 template<> struct supported_iterator_type<T> { enum { value = true }; };
15759 #define strtk_register_inrange_type_tag(T)\
15760 template<> struct supported_conversion_to_type<strtk::details::inrange_impl<T> > { typedef inrange_type_tag type; };\
15761 template<> struct supported_iterator_type<strtk::details::inrange_impl<T> > { enum { value = true }; };\
15763 #define strtk_register_trim_type_tag(T)\
15764 template<> struct supported_conversion_to_type<strtk::details::trim_impl<T> > { typedef trim_type_tag type; };\
15765 template<> struct supported_iterator_type<strtk::details::trim_impl<T> > { enum { value = true }; };
15767 #define strtk_register_stdstring_range_type_tag(T)\
15768 template<> struct supported_conversion_to_type< std::pair<T,T> >{ typedef stdstring_range_type_tag type; };
15770 #define strtk_register_sink_type_tag(T)\
15771 template<> struct supported_conversion_to_type<sink_type<std::vector<T> > > { typedef sink_type_tag type; };\
15772 template<> struct supported_conversion_to_type<sink_type<std::deque<T> > > { typedef sink_type_tag type; };\
15773 template<> struct supported_conversion_to_type<sink_type<std::list<T> > > { typedef sink_type_tag type; };\
15774 template<> struct supported_conversion_to_type<sink_type<std::set<T> > > { typedef sink_type_tag type; };\
15775 template<> struct supported_conversion_to_type<sink_type<std::multiset<T> > > { typedef sink_type_tag type; };\
15776 template<> struct supported_conversion_to_type<sink_type<std::queue<T> > > { typedef sink_type_tag type; };\
15777 template<> struct supported_conversion_to_type<sink_type<std::stack<T> > > { typedef sink_type_tag type; };\
15778 template<> struct supported_conversion_to_type<sink_type<std::priority_queue<T> > > { typedef sink_type_tag type; };\
15779 template<> struct supported_conversion_from_type<sink_type<std::vector<T> > > { typedef sink_type_tag type; };\
15780 template<> struct supported_conversion_from_type<sink_type<std::deque<T> > > { typedef sink_type_tag type; };\
15781 template<> struct supported_conversion_from_type<sink_type<std::list<T> > > { typedef sink_type_tag type; };\
15782 template<> struct supported_conversion_from_type<sink_type<std::set<T> > > { typedef sink_type_tag type; };\
15783 template<> struct supported_conversion_from_type<sink_type<std::multiset<T> > > { typedef sink_type_tag type; };\
15784 template<> struct supported_conversion_from_type<sink_type<std::queue<T> > > { typedef sink_type_tag type; };\
15785 template<> struct supported_conversion_from_type<sink_type<std::stack<T> > > { typedef sink_type_tag type; };\
15786 template<> struct supported_conversion_from_type<sink_type<std::priority_queue<T> > > { typedef sink_type_tag type; };\
15788 #define strtk_register_stl_container_to_string_conv_type_tag(T)\
15789 template<> struct supported_conversion_from_type<std::vector<T> > { typedef stl_seq_type_tag type; };\
15790 template<> struct supported_conversion_from_type<std::deque<T> > { typedef stl_seq_type_tag type; };\
15791 template<> struct supported_conversion_from_type<std::list<T> > { typedef stl_seq_type_tag type; };\
15792 template<> struct supported_conversion_from_type<std::set<T> > { typedef stl_seq_type_tag type; };\
15793 template<> struct supported_conversion_from_type<std::multiset<T> > { typedef stl_seq_type_tag type; };\
15794 template<> struct supported_conversion_from_type<std::queue<T> > { typedef stl_seq_type_tag type; };\
15795 template<> struct supported_conversion_from_type<std::stack<T> > { typedef stl_seq_type_tag type; };\
15796 template<> struct supported_conversion_from_type<std::priority_queue<T> > { typedef stl_seq_type_tag type; };\
15800 #define strtk_register_sequence_iterator_type(sequence)\
15801 strtk_register_supported_iterator_type(sequence<char>::iterator)\
15802 strtk_register_supported_iterator_type(sequence<char>::const_iterator)\
15803 strtk_register_supported_iterator_type(sequence<unsigned char>::iterator)\
15804 strtk_register_supported_iterator_type(sequence<unsigned char>::const_iterator)
15920 #define strtk_register_userdef_type_sink(T)\
15921 namespace strtk { namespace details { strtk_register_sink_type_tag(T) }}
15923 #undef strtk_register_unsigned_type_tag
15924 #undef strtk_register_signed_type_tag
15925 #undef strtk_register_real_type_tag
15926 #undef strtk_register_byte_type_tag
15927 #undef strtk_register_hex_number_type_tag
15928 #undef strtk_register_base64_type_tag
15929 #undef strtk_register_supported_iterator_type
15930 #undef strtk_register_stdstring_range_type_tag
15931 #undef strtk_register_sequence_iterator_type
15932 #undef strtk_register_stl_container_to_string_conv_type_tag
15933 #undef strtk_register_inrange_type_tag
15934 #undef strtk_register_trim_type_tag
15936 template <
typename T>
15938 {
static void set(std::iostream&) {} };
15940 #define strtk_register_iostream_precision(T)\
15941 template<> struct precision<T> { static void set(std::iostream& s, const std::streamsize& p = 10) { s.precision(p);} };
15947 #undef strtk_register_iostream_precision
15949 template <
typename Iterator,
typename T,
typename Tag>
15952 #ifdef strtk_enable_lexical_cast
15957 catch (
const boost::bad_lexical_cast&)
15969 catch (
const std::exception&)
15978 template <
typename Iterator>
15981 return v(begin,end);
15984 template <
typename Iterator>
15987 t.assign(begin,end);
15992 template <
typename Iterator,
typename Expect>
16001 template <
typename Iterator,
typename Like>
16010 template <
typename Iterator,
typename InRange>
16019 template <
typename Iterator,
typename TrimToken>
16028 template <
typename Iterator,
typename CaseToken>
16037 template <
typename Iterator,
typename CaseToken>
16046 template <
typename Iterator,
typename Array>
16055 template <
typename Iterator,
typename T>
16058 if (end == itr_external)
return false;
16060 Iterator itr = itr_external;
16068 while ((end != itr) && (
'0' == (*itr))) ++itr;
16079 std::size_t interim_length = std::min<std::size_t>(bound_length,length);
16080 const Iterator interim_end = itr + interim_length;
16081 unsigned int digit[8];
16089 #pragma warning(push)
16090 #pragma warning(disable: 4127)
16093 while (interim_length > 7)
16095 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16096 ((digit[1] = (itr[1] -
'0')) > 9) ||
16097 ((digit[2] = (itr[2] -
'0')) > 9) ||
16098 ((digit[3] = (itr[3] -
'0')) > 9) ||
16099 ((digit[4] = (itr[4] -
'0')) > 9) ||
16100 ((digit[5] = (itr[5] -
'0')) > 9) ||
16101 ((digit[6] = (itr[6] -
'0')) > 9) ||
16102 ((digit[7] = (itr[7] -
'0')) > 9))
16106 t0 =
static_cast<T>(digit[0] * 10000000 + digit[1] * 1000000);
16107 t1 =
static_cast<T>(digit[2] * 100000 + digit[3] * 10000);
16108 t2 =
static_cast<T>(digit[4] * 1000 + digit[5] * 100);
16109 t3 =
static_cast<T>(digit[6] * 10 + digit[7] );
16110 t = t0 + t1 + t2 + t3 +
static_cast<T>(t * 100000000);
16112 interim_length -= 8;
16116 while (interim_length > 3)
16118 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16119 ((digit[1] = (itr[1] -
'0')) > 9) ||
16120 ((digit[2] = (itr[2] -
'0')) > 9) ||
16121 ((digit[3] = (itr[3] -
'0')) > 9))
16125 t1 =
static_cast<T>(digit[0] * 1000 + digit[1] * 100);
16126 t2 =
static_cast<T>(digit[2] * 10 + digit[3] );
16127 t3 =
static_cast<T>(t * 10000 );
16130 interim_length -= 4;
16134 while (interim_length > 1)
16136 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16137 ((digit[1] = (itr[1] -
'0')) > 9))
16141 t1 =
static_cast<T>(digit[0] * 10 + digit[1]);
16142 t2 =
static_cast<T>(t * 100 );
16145 interim_length -= 2;
16151 #pragma warning(pop)
16154 if (interim_length)
16156 if ((digit[0] = (itr[0] -
'0')) < 10)
16158 t =
static_cast<T>(digit[0] + t * 10);
16165 if (interim_end != end)
16169 typedef unsigned long long int num_type;
16170 static const num_type max =
static_cast<num_type
>(std::numeric_limits<T>::max());
16171 static const num_type penultimate_bound =
static_cast<num_type
>(max / 10);
16172 static const num_type final_digit =
static_cast<num_type
>(max % 10);
16174 digit[0] =
static_cast<unsigned int>(*itr -
'0');
16177 if (t > penultimate_bound)
16179 else if ((penultimate_bound == t) && (final_digit < digit[0]))
16181 t =
static_cast<T>(digit[0] + t * 10);
16191 result =
static_cast<T>(t);
16195 template <
typename Iterator,
typename T>
16198 if (end == itr_external)
return false;
16200 Iterator itr = itr_external;
16202 bool negative =
false;
16206 else if (
'-' == (*itr))
16212 if (end == itr)
return false;
16214 while ((end != itr) && (
'0' == (*itr))) ++itr;
16226 std::size_t interim_length = std::min<std::size_t>(bound_length,length);
16227 const Iterator interim_end = itr + interim_length;
16228 unsigned int digit[8];
16236 #pragma warning(push)
16237 #pragma warning(disable: 4127)
16240 while (interim_length > 7)
16242 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16243 ((digit[1] = (itr[1] -
'0')) > 9) ||
16244 ((digit[2] = (itr[2] -
'0')) > 9) ||
16245 ((digit[3] = (itr[3] -
'0')) > 9) ||
16246 ((digit[4] = (itr[4] -
'0')) > 9) ||
16247 ((digit[5] = (itr[5] -
'0')) > 9) ||
16248 ((digit[6] = (itr[6] -
'0')) > 9) ||
16249 ((digit[7] = (itr[7] -
'0')) > 9) )
16253 t0 =
static_cast<T>(digit[0] * 10000000 + digit[1] * 1000000);
16254 t1 =
static_cast<T>(digit[2] * 100000 + digit[3] * 10000);
16255 t2 =
static_cast<T>(digit[4] * 1000 + digit[5] * 100);
16256 t3 =
static_cast<T>(digit[6] * 10 + digit[7] );
16257 t = t0 + t1 + t2 + t3 +
static_cast<T>(t * 100000000);
16259 interim_length -= 8;
16263 while (interim_length > 3)
16265 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16266 ((digit[1] = (itr[1] -
'0')) > 9) ||
16267 ((digit[2] = (itr[2] -
'0')) > 9) ||
16268 ((digit[3] = (itr[3] -
'0')) > 9) )
16272 t0 =
static_cast<T>(digit[0] * 1000 + digit[1] * 100);
16273 t1 =
static_cast<T>(digit[2] * 10 + digit[3] );
16274 t = t0 + t1 +
static_cast<T>(t * 10000);
16276 interim_length -= 4;
16280 while (interim_length > 2)
16282 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16283 ((digit[1] = (itr[1] -
'0')) > 9) ||
16284 ((digit[2] = (itr[2] -
'0')) > 9))
16288 t0 =
static_cast<T>(digit[0] * 100 + digit[1] * 10);
16289 t1 =
static_cast<T>(t * 1000 + digit[2] );
16292 interim_length -= 3;
16296 while (interim_length > 1)
16298 if (((digit[0] = (itr[0] -
'0')) > 9) ||
16299 ((digit[1] = (itr[1] -
'0')) > 9))
16303 t0 =
static_cast<T>(digit[0] * 10 + digit[1]);
16304 t = t0 +
static_cast<T>(t * 100);
16306 interim_length -= 2;
16312 #pragma warning(pop)
16315 if (interim_length)
16317 if ((digit[0] = (itr[0] -
'0')) < 10)
16319 t =
static_cast<T>(digit[0] + t * 10);
16326 if (interim_end != end)
16330 typedef unsigned long long int num_type;
16331 static const num_type max =
static_cast<num_type
>(std::numeric_limits<T>::max());
16332 static const num_type min =
static_cast<num_type
>(
static_cast<long long>(-1) * std::numeric_limits<T>::min());
16333 static const num_type positive_penultimate_bound =
static_cast<num_type
>(max / 10);
16334 static const num_type negative_penultimate_bound =
static_cast<num_type
>(min / 10);
16335 static const num_type positive_final_digit =
static_cast<num_type
>(max % 10);
16336 static const num_type negative_final_digit =
static_cast<num_type
>(min % 10);
16338 digit[0] =
static_cast<unsigned int>(*itr -
'0');
16344 if (static_cast<num_type>(t) > negative_penultimate_bound)
16347 (negative_penultimate_bound == static_cast<num_type>(t)) &&
16348 (negative_final_digit < digit[0])
16354 if (static_cast<num_type>(t) > positive_penultimate_bound)
16357 (positive_penultimate_bound == static_cast<num_type>(t)) &&
16358 (positive_final_digit < digit[0])
16362 t =
static_cast<T>(digit[0] + t * 10);
16371 itr_external = itr;
16372 result =
static_cast<T>((negative) ? -t : t);
16376 template <
typename Iterator,
typename T>
16379 if (end == itr)
return false;
16382 bool negative =
false;
16386 else if (
'-' == (*itr))
16395 unsigned int digit_count = 0;
16396 while ((end != itr) && (
'0' == (*itr))) ++itr;
16398 bool return_result =
true;
16401 const unsigned char digit = (*itr -
'0');
16404 return_result =
false;
16415 typedef unsigned long long int base_type;
16416 static const base_type max_limit = +std::numeric_limits<T>::max();
16417 static const base_type min_limit = -std::numeric_limits<T>::min();
16418 base_type tmp =
static_cast<base_type
>(t) * 10 + digit;
16419 if (negative && static_cast<base_type>(tmp) > min_limit)
16420 return_result =
false;
16421 else if (static_cast<base_type>(tmp) > max_limit)
16422 return_result =
false;
16423 t =
static_cast<T>(tmp);
16428 result =
static_cast<T>((negative) ? -t : t);
16429 return return_result;
16432 template <
typename Iterator,
typename T>
16435 typedef typename std::iterator_traits<Iterator>::value_type
type;
16436 static const std::size_t nan_length = 3;
16437 if (
std::distance(itr,end) != static_cast<int>(nan_length))
16439 if (static_cast<type>(
'n') == (*itr))
16441 if ((static_cast<type>(
'a') != *(itr + 1)) || (static_cast<type>(
'n') != *(itr + 2)))
16446 else if ((static_cast<type>(
'A') != *(itr + 1)) || (static_cast<type>(
'N') != *(itr + 2)))
16450 t = std::numeric_limits<T>::quiet_NaN();
16454 template <
typename Iterator,
typename T>
16455 inline bool parse_inf(Iterator& itr,
const Iterator end,
T& t,
bool negative)
16457 static const char inf_uc[] =
"INFINITY";
16458 static const char inf_lc[] =
"infinity";
16459 static const std::size_t inf_length = 8;
16461 if ((3 != length) && (inf_length != length))
16463 const char* inf_itr = (
'i' == (*itr)) ? inf_lc : inf_uc;
16466 if (*inf_itr == static_cast<char>(*itr))
16476 t = -std::numeric_limits<T>::infinity();
16478 t = std::numeric_limits<T>::infinity();
16482 template <
typename Iterator,
typename T>
16485 if (end == itr_external)
return false;
16486 Iterator itr = itr_external;
16488 bool negative =
false;
16491 else if (
'-' == (*itr))
16500 if ((
'I' <= (*itr)) && ((*itr) <=
'n'))
16502 if ((
'i' == (*itr)) || (
'I' == (*itr)))
16506 else if ((
'n' == (*itr)) || (
'N' == (*itr)))
16514 bool instate =
false;
16515 int pre_decimal = 0;
16519 const Iterator curr = itr;
16520 while ((end != itr) && (
'0' == (*itr))) ++itr;
16521 const Iterator post_zero_cull_itr = itr;
16522 unsigned char digit = 0;
16524 #define parse_digit_1 \
16525 if ((digit = static_cast<unsigned char>((*itr) - '0')) < 10) { d *= 10.0; d += digit; } else break; if (end == ++itr) break; \
16527 #define parse_digit_2 \
16528 if ((digit = static_cast<unsigned char>((*itr) - '0')) < 10) { d *= 10.0; d += digit; } else break; ++itr;\
16541 #undef parse_digit_1
16542 #undef parse_digit_2
16543 if (curr != itr) instate =
true;
16544 pre_decimal =
static_cast<int>(
std::distance(post_zero_cull_itr,itr));
16554 const Iterator curr = itr;
16555 unsigned char digit = 0;
16557 #define parse_digit_1 \
16558 if ((digit = static_cast<unsigned char>((*itr) - '0')) < 10) { d *= 10.0; d += digit; } else break; if (end == ++itr) break; \
16560 #define parse_digit_2 \
16561 if ((digit = static_cast<unsigned char>((*itr) - '0')) < 10) { d *= 10.0; d += digit; } else break; ++itr;\
16574 #undef parse_digit_1
16575 #undef parse_digit_2
16576 if (curr != itr) instate =
true;
16582 typename std::iterator_traits<Iterator>::value_type c = (*itr);
16584 if ((
'e' == c) || (
'E' == c))
16602 if ((
'f' == c) || (
'F' == c) || (
'l' == c) || (
'L' == c))
16609 if ((10.0 != d) || (exponent != -1))
16611 if ((
'I' <= (*itr)) && ((*itr) <=
'n'))
16613 if ((
'i' == (*itr)) || (
'I' == (*itr)))
16617 else if ((
'n' == (*itr)) || (
'N' == (*itr)))
16629 if ((end != itr) || (!instate))
16635 (std::numeric_limits<T>::max_exponent10 < (exponent + pre_decimal)) ||
16636 (std::numeric_limits<T>::min_exponent10 > (exponent + pre_decimal))
16642 const int e = std::abs(exponent);
16643 static const double fract10[] =
16646 1.0E+001, 1.0E+002, 1.0E+003, 1.0E+004, 1.0E+005, 1.0E+006, 1.0E+007, 1.0E+008, 1.0E+009, 1.0E+010,
16647 1.0E+011, 1.0E+012, 1.0E+013, 1.0E+014, 1.0E+015, 1.0E+016, 1.0E+017, 1.0E+018, 1.0E+019, 1.0E+020,
16648 1.0E+021, 1.0E+022, 1.0E+023, 1.0E+024, 1.0E+025, 1.0E+026, 1.0E+027, 1.0E+028, 1.0E+029, 1.0E+030,
16649 1.0E+031, 1.0E+032, 1.0E+033, 1.0E+034, 1.0E+035, 1.0E+036, 1.0E+037, 1.0E+038, 1.0E+039, 1.0E+040,
16650 1.0E+041, 1.0E+042, 1.0E+043, 1.0E+044, 1.0E+045, 1.0E+046, 1.0E+047, 1.0E+048, 1.0E+049, 1.0E+050,
16651 1.0E+051, 1.0E+052, 1.0E+053, 1.0E+054, 1.0E+055, 1.0E+056, 1.0E+057, 1.0E+058, 1.0E+059, 1.0E+060,
16652 1.0E+061, 1.0E+062, 1.0E+063, 1.0E+064, 1.0E+065, 1.0E+066, 1.0E+067, 1.0E+068, 1.0E+069, 1.0E+070,
16653 1.0E+071, 1.0E+072, 1.0E+073, 1.0E+074, 1.0E+075, 1.0E+076, 1.0E+077, 1.0E+078, 1.0E+079, 1.0E+080,
16654 1.0E+081, 1.0E+082, 1.0E+083, 1.0E+084, 1.0E+085, 1.0E+086, 1.0E+087, 1.0E+088, 1.0E+089, 1.0E+090,
16655 1.0E+091, 1.0E+092, 1.0E+093, 1.0E+094, 1.0E+095, 1.0E+096, 1.0E+097, 1.0E+098, 1.0E+099, 1.0E+100,
16656 1.0E+101, 1.0E+102, 1.0E+103, 1.0E+104, 1.0E+105, 1.0E+106, 1.0E+107, 1.0E+108, 1.0E+109, 1.0E+110,
16657 1.0E+111, 1.0E+112, 1.0E+113, 1.0E+114, 1.0E+115, 1.0E+116, 1.0E+117, 1.0E+118, 1.0E+119, 1.0E+120,
16658 1.0E+121, 1.0E+122, 1.0E+123, 1.0E+124, 1.0E+125, 1.0E+126, 1.0E+127, 1.0E+128, 1.0E+129, 1.0E+130,
16659 1.0E+131, 1.0E+132, 1.0E+133, 1.0E+134, 1.0E+135, 1.0E+136, 1.0E+137, 1.0E+138, 1.0E+139, 1.0E+140,
16660 1.0E+141, 1.0E+142, 1.0E+143, 1.0E+144, 1.0E+145, 1.0E+146, 1.0E+147, 1.0E+148, 1.0E+149, 1.0E+150,
16661 1.0E+151, 1.0E+152, 1.0E+153, 1.0E+154, 1.0E+155, 1.0E+156, 1.0E+157, 1.0E+158, 1.0E+159, 1.0E+160,
16662 1.0E+161, 1.0E+162, 1.0E+163, 1.0E+164, 1.0E+165, 1.0E+166, 1.0E+167, 1.0E+168, 1.0E+169, 1.0E+170,
16663 1.0E+171, 1.0E+172, 1.0E+173, 1.0E+174, 1.0E+175, 1.0E+176, 1.0E+177, 1.0E+178, 1.0E+179, 1.0E+180,
16664 1.0E+181, 1.0E+182, 1.0E+183, 1.0E+184, 1.0E+185, 1.0E+186, 1.0E+187, 1.0E+188, 1.0E+189, 1.0E+190,
16665 1.0E+191, 1.0E+192, 1.0E+193, 1.0E+194, 1.0E+195, 1.0E+196, 1.0E+197, 1.0E+198, 1.0E+199, 1.0E+200,
16666 1.0E+221, 1.0E+222, 1.0E+223, 1.0E+224, 1.0E+225, 1.0E+226, 1.0E+227, 1.0E+228, 1.0E+229, 1.0E+230,
16667 1.0E+231, 1.0E+232, 1.0E+233, 1.0E+234, 1.0E+235, 1.0E+236, 1.0E+237, 1.0E+238, 1.0E+239, 1.0E+240,
16668 1.0E+241, 1.0E+242, 1.0E+243, 1.0E+244, 1.0E+245, 1.0E+246, 1.0E+247, 1.0E+248, 1.0E+249, 1.0E+250,
16669 1.0E+251, 1.0E+252, 1.0E+253, 1.0E+254, 1.0E+255, 1.0E+256, 1.0E+257, 1.0E+258, 1.0E+259, 1.0E+260,
16670 1.0E+261, 1.0E+262, 1.0E+263, 1.0E+264, 1.0E+265, 1.0E+266, 1.0E+267, 1.0E+268, 1.0E+269, 1.0E+270,
16671 1.0E+271, 1.0E+272, 1.0E+273, 1.0E+274, 1.0E+275, 1.0E+276, 1.0E+277, 1.0E+278, 1.0E+279, 1.0E+280,
16672 1.0E+281, 1.0E+282, 1.0E+283, 1.0E+284, 1.0E+285, 1.0E+286, 1.0E+287, 1.0E+288, 1.0E+289, 1.0E+290,
16673 1.0E+291, 1.0E+292, 1.0E+293, 1.0E+294, 1.0E+295, 1.0E+296, 1.0E+297, 1.0E+298, 1.0E+299, 1.0E+300,
16674 1.0E+301, 1.0E+302, 1.0E+303, 1.0E+304, 1.0E+305, 1.0E+306, 1.0E+307, 1.0E+308
16677 static const std::size_t fract10_size =
sizeof(fract10) /
sizeof(
double);
16681 if (static_cast<std::size_t>(e) < fract10_size)
16689 d *= std::pow(10.0, 1.0 * exponent);
16693 t =
static_cast<T>((negative) ? -d : d);
16697 template <
typename Iterator,
typename T>
16702 t =
static_cast<T>(*itr);
16707 template <
typename Iterator>
16712 t = ((
'0' == (*itr)) ?
false :
true);
16717 template <
typename Iterator,
typename IgnoreTokenType>
16724 template <
typename Iterator,
typename HexSinkType>
16727 t = std::pair<Iterator,Iterator>(itr,end);
16734 template <
typename Iterator,
typename HexSinkType>
16737 t = std::pair<Iterator,Iterator>(itr,end);
16744 template <
typename Iterator,
typename Base64SinkType>
16747 t = std::pair<Iterator,Iterator>(itr,end);
16754 template <
typename Iterator,
typename SinkType>
16757 if (!t.parse(itr,end))
16763 template <
typename T>
16766 #ifdef strtk_enable_lexical_cast
16771 catch (
const boost::bad_lexical_cast&)
16778 std::stringstream ss;
16779 precision<T>::set(ss);
16783 catch (
const std::exception&)
16791 template <
typename T>
16794 static const std::size_t radix = 10;
16795 static const std::size_t radix_sqr = radix * radix;
16796 static const std::size_t radix_cube = radix * radix * radix;
16803 std::size_t index = 0;
16805 while (value >= static_cast<T>(radix_sqr))
16807 temp_v = value / radix_cube;
16808 remainder = value - (temp_v * radix_cube);
16810 index =
static_cast<std::size_t
>(remainder * 3);
16811 *(itr ) = details::rev_3digit_lut[index ];
16812 *(itr - 1) = details::rev_3digit_lut[index + 1];
16813 *(itr - 2) = details::rev_3digit_lut[index + 2];
16817 while (value >= static_cast<T>(radix))
16819 temp_v = value / radix_sqr;
16820 remainder = value - (temp_v * radix_sqr);
16822 index =
static_cast<std::size_t
>(remainder << 1);
16823 *(itr--) = details::rev_2digit_lut[index + 0];
16824 *(itr--) = details::rev_2digit_lut[index + 1];
16829 *(itr--) = strtk::details::digitr[value];
16836 result.assign(reinterpret_cast<char*>(itr), (buffer +
numeric<T>::size) - itr);
16840 template <
typename T>
16843 static const std::size_t radix = 10;
16844 static const std::size_t radix_sqr = radix * radix;
16845 static const std::size_t radix_cube = radix * radix * radix;
16848 bool negative = (value < 0);
16850 value =
static_cast<T>(-1 * value);
16855 std::size_t index = 0;
16857 while (value >= static_cast<T>(radix_sqr))
16859 temp_v = value / radix_cube;
16860 remainder = value - (temp_v * radix_cube);
16862 index =
static_cast<std::size_t
>(remainder * 3);
16863 *(itr ) = details::rev_3digit_lut[index ];
16864 *(itr - 1) = details::rev_3digit_lut[index + 1];
16865 *(itr - 2) = details::rev_3digit_lut[index + 2];
16869 while (value >= static_cast<T>(radix))
16871 temp_v = value / radix_sqr;
16872 remainder = value - (temp_v * radix_sqr);
16874 index =
static_cast<std::size_t
>(remainder) << 1;
16875 *(itr ) = details::rev_2digit_lut[index ];
16876 *(itr - 1) = details::rev_2digit_lut[index + 1];
16882 *(itr--) = strtk::details::digitr[value];
16888 if (negative) *(itr--) =
'-';
16891 result.assign(reinterpret_cast<char*>(itr), (buffer +
numeric<T>::size) - itr);
16895 template <
typename T>
16899 result[0] =
static_cast<char>(value);
16906 result[0] = value ?
'1' :
'0';
16916 template <
typename Iterator>
16919 result.assign(range.first,range.second);
16923 template <
typename SinkType>
16930 template <
typename STLContainerType>
16937 template <
typename T>
16944 #define strtk_register_type_name(Type)\
16945 template <> inline std::string type_name<Type>() { static const std::string s(#Type); return s; }
16962 #undef strtk_register_type_name
16964 template <
typename T>
16971 template <
typename T1,
typename T2>
16982 template <
typename T>
16988 template <
typename T>
16991 return type_length<T>();
16999 template <
typename T1,
typename T2>
17002 return type_length<T1>() + type_length<T2>();
17007 template <
typename T>
17010 static const std::string s = details::type_name<T>(t);
17014 template <
typename T, std::
size_t N>
17017 static const std::string s = details::type_name<T>() +
17022 template <
typename T1,
typename T2>
17033 #define strtk_register_sequence_type_name(Type)\
17034 template <typename T, typename Allocator>\
17035 inline std::string type_name(const Type<T,Allocator>&)\
17037 static const std::string s = std::string(#Type) + std::string("<" + details::type_name<T>() + ">");\
17041 #define strtk_register_set_type_name(Type)\
17042 template <typename T, typename Comparator, typename Allocator>\
17043 inline std::string type_name(const Type<T,Comparator,Allocator>&)\
17045 static const std::string s = std::string(#Type) + std::string("<" + details::type_name<T>() + ">");\
17055 template <typename
T>
17058 return details::type_length<T>();
17061 template <
typename T>
17064 return type_length<T>();
17083 : s_(r.begin(),r.end())
17090 template <
typename T>
17117 template <
typename T>
17120 return string_to_type_converter<T>(s_);
17123 template <
typename T>
17151 template <
typename Predicate>
17154 if (s_.empty())
return (*
this);
17161 if (removal_set.empty())
17163 else if (1 == removal_set.size())
17170 template <
typename Predicate>
17173 if (s_.empty())
return (*
this);
17180 if (removal_set.empty())
17182 else if (1 == removal_set.size())
17189 template <
typename T>
17211 result.reserve(s_.size());
17216 template <
typename DelimiterPredicate,
typename OutputIterator>
17217 inline std::size_t
split(
const DelimiterPredicate& p,
17218 OutputIterator out,
17224 template <
typename DelimiterPredicate,
17225 typename Allocator,
17226 template <
typename,
typename>
class Sequence>
17227 inline std::size_t
split(
const DelimiterPredicate& p,
17228 Sequence<std::string,Allocator>& seq,
17234 template <
typename DelimiterPredicate,
typename OutputIterator>
17235 inline std::size_t
split_n(
const DelimiterPredicate& p,
17236 const std::size_t& n,
17237 OutputIterator out,
17243 template <
typename DelimiterPredicate,
17244 typename Allocator,
17245 template <
typename,
typename>
class Sequence>
17246 inline std::size_t
split_n(
const DelimiterPredicate& p,
17247 const std::size_t& n,
17248 Sequence<std::string,Allocator>& seq,
17254 template <
typename T,
17255 typename Allocator,
17256 template <
typename,
typename>
class Sequence>
17262 template <
typename T,
17263 typename Allocator,
17264 template <
typename,
typename>
class Sequence>
17265 inline std::size_t
parse(
const char* delimiters, Sequence<T,Allocator>& seq)
const
17273 template <
typename T>
17276 template <
typename T>
17291 static const ext_string letters(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
17313 static_cast<std::string::value_type
>(0x00));
17332 template <
typename T>
17338 template <
typename T>
17347 tmp.reserve(s.s_.size());
17362 static inline std::ostream& operator<<(std::ostream& os,
const ext_string& es)
17364 return (os << es.as_string());
17372 std::ifstream file(file_name.c_str(), std::ios::binary);
17373 return ((!file) ?
false :
true);
17378 std::ifstream file(file_name.c_str(),std::ios::binary);
17379 if (!file)
return 0;
17380 file.seekg (0, std::ios::end);
17381 return static_cast<std::size_t
>(file.tellg());
17386 std::ifstream in_stream(file_name.c_str(),std::ios::binary);
17387 if (!in_stream)
return false;
17388 in_stream.read(buffer,static_cast<std::streamsize>(buffer_size));
17396 return load_file(file_name,const_cast<char*>(buffer.data()),buffer.size());
17401 std::ofstream out_stream(file_name.c_str(),std::ios::binary);
17402 if (!out_stream)
return false;
17403 out_stream.write(buffer,static_cast<std::streamsize>(buffer_size));
17404 out_stream.close();
17410 return write_file(file_name,const_cast<char*>(buffer.data()),buffer.size());
17415 std::ifstream src_file(src_file_name.c_str(),std::ios::binary);
17416 std::ofstream dest_file(dest_file_name.c_str(),std::ios::binary);
17417 if (!src_file)
return false;
17418 if (!dest_file)
return false;
17420 static const std::size_t block_size = 16 * one_kilobyte;
17421 char buffer[block_size];
17423 std::size_t remaining_bytes =
file_size(src_file_name);
17425 while (remaining_bytes >= block_size)
17427 src_file.read(&buffer[0],static_cast<std::streamsize>(block_size));
17428 dest_file.write(&buffer[0],static_cast<std::streamsize>(block_size));
17429 remaining_bytes -= block_size;
17432 if (remaining_bytes > 0)
17434 src_file.read(&buffer[0],static_cast<std::streamsize>(remaining_bytes));
17435 dest_file.write(&buffer[0],static_cast<std::streamsize>(remaining_bytes));
17436 remaining_bytes = 0;
17448 std::ifstream file1(file_name1.c_str(),std::ios::binary);
17449 std::ifstream file2(file_name2.c_str(),std::ios::binary);
17450 std::ofstream out_file(output_file_name.c_str(),std::ios::binary);
17452 if (!file1 || !file2 || !out_file)
return false;
17454 static const std::size_t block_size = 16 * one_kilobyte;
17455 char buffer[block_size];
17456 unsigned int round = 0;
17457 std::size_t remaining_bytes = 0;
17461 std::ifstream& input_stream = ((0 ==
round) ? file1 : file2);
17464 while (remaining_bytes >= block_size)
17466 input_stream.read(&buffer[0],static_cast<std::streamsize>(block_size));
17467 out_file.write(&buffer[0],static_cast<std::streamsize>(block_size));
17468 remaining_bytes -= block_size;
17471 if (remaining_bytes > 0)
17473 input_stream.read(&buffer[0],static_cast<std::streamsize>(remaining_bytes));
17474 out_file.write(&buffer[0],static_cast<std::streamsize>(remaining_bytes));
17475 remaining_bytes = 0;
17478 input_stream.close();
17487 std::ifstream file1(file_name1.c_str(),std::ios::binary);
17488 std::ifstream file2(file_name2.c_str(),std::ios::binary);
17489 if (!file1)
return false;
17490 if (!file2)
return false;
17493 static const std::size_t block_size = 16 * one_kilobyte;
17494 char buffer1[block_size];
17495 char buffer2[block_size];
17497 std::size_t remaining_bytes =
file_size(file_name1);
17499 while (remaining_bytes >= block_size)
17501 file1.read(&buffer1[0],static_cast<std::streamsize>(block_size));
17502 file2.read(&buffer2[0],static_cast<std::streamsize>(block_size));
17503 if (0 != std::memcmp(buffer1,buffer2,block_size))
17505 remaining_bytes -= block_size;
17508 if (remaining_bytes > 0)
17510 file1.read(&buffer1[0],static_cast<std::streamsize>(remaining_bytes));
17511 file2.read(&buffer2[0],static_cast<std::streamsize>(remaining_bytes));
17512 if (0 != std::memcmp(buffer1,buffer2,remaining_bytes))
17514 remaining_bytes = 0;
17525 template <
typename T>
17528 return (
false == stream.read(reinterpret_cast<char*>(&t),
17529 static_cast<std::streamsize>(
sizeof(
T))).fail());
17532 template <
typename T>
17535 return (
false == stream.write(reinterpret_cast<char*>(&t),
17536 static_cast<std::streamsize>(
sizeof(
T))).fail());
17540 template <
typename T1,
typename T2,
typename T3,
typename T4,
17541 typename T5,
typename T6,
typename T7,
typename T8,
17542 typename T9,
typename T10>
17544 T1& t1, T2& t2, T3& t3, T4& t4,
17545 T5& t5, T6& t6, T7& t7, T8& t8,
17560 template <
typename T1,
typename T2,
typename T3,
typename T4,
17561 typename T5,
typename T6,
typename T7,
typename T8,
17564 T1& t1, T2& t2, T3& t3, T4& t4,
17565 T5& t5, T6& t6, T7& t7, T8& t8,
17579 template <
typename T1,
typename T2,
typename T3,
typename T4,
17580 typename T5,
typename T6,
typename T7,
typename T8>
17582 T1& t1, T2& t2, T3& t3, T4& t4,
17583 T5& t5, T6& t6, T7& t7, T8& t8)
17595 template <
typename T1,
typename T2,
typename T3,
typename T4,
17596 typename T5,
typename T6,
typename T7>
17598 T1& t1, T2& t2, T3& t3, T4& t4,
17599 T5& t5, T6& t6, T7& t7)
17610 template <
typename T1,
typename T2,
typename T3,
typename T4,
17611 typename T5,
typename T6>
17613 T1& t1, T2& t2, T3& t3, T4& t4,
17624 template <
typename T1,
typename T2,
typename T3,
typename T4,
17627 T1& t1, T2& t2, T3& t3, T4& t4,
17637 template <
typename T1,
typename T2,
typename T3,
typename T4>
17639 T1& t1, T2& t2, T3& t3, T4& t4)
17647 template <
typename T1,
typename T2,
typename T3>
17649 T1& t1, T2& t2, T3& t3)
17656 template <
typename T1,
typename T2>
17664 template <
typename T>
17670 template <
typename T, std::
size_t N>
17673 return (
false != stream.read(reinterpret_cast<char*>(&t[0]),
sizeof(
T) * N).fail());
17676 template <
typename T,
17677 typename Allocator,
17678 template <
typename,
typename>
class Sequence>
17680 const std::size_t& count,
17681 Sequence<T,Allocator>& sequence)
17684 for (std::size_t i = 0; i < count; ++i)
17687 sequence.push_back(t);
17694 template <
typename T,
17695 typename Comparator,
17696 typename Allocator>
17698 const std::size_t& count,
17699 std::set<T,Comparator,Allocator>& set)
17702 for (std::size_t i = 0; i < count; ++i)
17712 template <
typename T,
17713 typename Comparator,
17714 typename Allocator>
17716 const std::size_t& count,
17717 std::multiset<T,Comparator,Allocator>& multiset)
17720 for (std::size_t i = 0; i < count; ++i)
17723 multiset.insert(t);
17730 template <
typename T1,
typename T2,
typename T3,
typename T4,
17731 typename T5,
typename T6,
typename T7,
typename T8,
17732 typename T9,
typename T10>
17734 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17735 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
17736 const T9& t9,
const T10& t10)
17750 template <
typename T1,
typename T2,
typename T3,
typename T4,
17751 typename T5,
typename T6,
typename T7,
typename T8,
17754 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17755 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
17769 template <
typename T1,
typename T2,
typename T3,
typename T4,
17770 typename T5,
typename T6,
typename T7,
typename T8>
17772 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17773 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8)
17785 template <
typename T1,
typename T2,
typename T3,
typename T4,
17786 typename T5,
typename T6,
typename T7>
17788 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17789 const T5& t5,
const T6& t6,
const T7& t7)
17800 template <
typename T1,
typename T2,
typename T3,
typename T4,
17801 typename T5,
typename T6>
17803 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17804 const T5& t5,
const T6& t6)
17814 template <
typename T1,
typename T2,
typename T3,
typename T4,
17817 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
17827 template <
typename T1,
typename T2,
typename T3,
typename T4>
17829 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4)
17837 template <
typename T1,
typename T2,
typename T3>
17839 const T1& t1,
const T2& t2,
const T3& t3)
17846 template <
typename T1,
typename T2>
17848 const T1& t1,
const T2& t2)
17854 template <
typename T>
17860 template <
typename T, std::
size_t N>
17863 return (
false != stream.write(reinterpret_cast<char*>(&t[0]),
sizeof(
T) * N).fail());
17866 template <
typename T,
17867 typename Allocator,
17868 template <
typename,
typename>
class Sequence>
17870 const Sequence<T,Allocator>& sequence)
17872 typename Sequence<T,Allocator>::iterator itr = sequence.begin();
17873 typename Sequence<T,Allocator>::iterator end = sequence.end();
17883 template <
typename T,
17884 typename Comparator,
17885 typename Allocator>
17887 const std::set<T,Comparator,Allocator>& set)
17889 typename std::set<T,Comparator,Allocator>::iterator itr = set.begin();
17890 typename std::set<T,Comparator,Allocator>::iterator end = set.end();
17900 template <
typename T,
17901 typename Comparator,
17902 typename Allocator>
17904 const std::multiset<T,Comparator,Allocator>& multiset)
17906 typename std::multiset<T,Comparator,Allocator>::iterator itr = multiset.begin();
17907 typename std::multiset<T,Comparator,Allocator>::iterator end = multiset.end();
17918 const std::size_t& offset,
17920 const std::size_t& buffer_size)
17922 if (!stream)
return false;
17923 stream.seekg(static_cast<std::ifstream::off_type>(offset),std::ios_base::beg);
17924 if (stream.fail())
return false;
17925 stream.read(buffer,static_cast<std::streamsize>(buffer_size));
17926 if (stream.fail())
return false;
17932 const std::size_t& offset,
17934 const std::size_t& buffer_size)
17936 std::ifstream stream(file_name.c_str(), std::ios::in | std::ios::binary);
17937 if (!stream)
return false;
17942 const std::size_t& offset,
17944 const std::size_t& buffer_size)
17946 std::ifstream stream(file_name.c_str(), std::ios::in | std::ios::binary);
17947 if (!stream)
return false;
17948 buffer.resize(buffer_size);
17951 const_cast<char*>(buffer.data()),
17957 template <
typename T1,
typename T2,
typename T3,
typename T4,
17958 typename T5,
typename T6,
typename T7,
typename T8,
17959 typename T9,
typename T10,
typename T11,
typename T12>
17961 T1& t1, T2& t2, T3& t3, T4& t4,
17962 T5& t5, T6& t6, T7& t7, T8& t8,
17963 T9& t9, T10& t10, T11& t11, T12& t12)
17965 t1 = (*
reinterpret_cast< T1*
>(data)); data +=
sizeof( T1);
17966 t2 = (*
reinterpret_cast< T2*
>(data)); data +=
sizeof( T2);
17967 t3 = (*
reinterpret_cast< T3*
>(data)); data +=
sizeof( T3);
17968 t4 = (*
reinterpret_cast< T4*
>(data)); data +=
sizeof( T4);
17969 t5 = (*
reinterpret_cast< T5*
>(data)); data +=
sizeof( T5);
17970 t6 = (*
reinterpret_cast< T6*
>(data)); data +=
sizeof( T6);
17971 t7 = (*
reinterpret_cast< T7*
>(data)); data +=
sizeof( T7);
17972 t8 = (*
reinterpret_cast< T8*
>(data)); data +=
sizeof( T8);
17973 t9 = (*
reinterpret_cast< T9*
>(data)); data +=
sizeof( T9);
17974 t10 = (*
reinterpret_cast<T10*
>(data)); data +=
sizeof(T10);
17975 t11 = (*
reinterpret_cast<T11*
>(data)); data +=
sizeof(T11);
17976 t12 = (*
reinterpret_cast<T12*
>(data)); data +=
sizeof(T12);
17980 template <
typename T1,
typename T2,
typename T3,
typename T4,
17981 typename T5,
typename T6,
typename T7,
typename T8,
17982 typename T9,
typename T10,
typename T11>
17984 T1& t1, T2& t2, T3& t3, T4& t4,
17985 T5& t5, T6& t6, T7& t7, T8& t8,
17986 T9& t9, T10& t10, T11& t11)
17988 t1 = (*
reinterpret_cast< T1*
>(data)); data +=
sizeof( T1);
17989 t2 = (*
reinterpret_cast< T2*
>(data)); data +=
sizeof( T2);
17990 t3 = (*
reinterpret_cast< T3*
>(data)); data +=
sizeof( T3);
17991 t4 = (*
reinterpret_cast< T4*
>(data)); data +=
sizeof( T4);
17992 t5 = (*
reinterpret_cast< T5*
>(data)); data +=
sizeof( T5);
17993 t6 = (*
reinterpret_cast< T6*
>(data)); data +=
sizeof( T6);
17994 t7 = (*
reinterpret_cast< T7*
>(data)); data +=
sizeof( T7);
17995 t8 = (*
reinterpret_cast< T8*
>(data)); data +=
sizeof( T8);
17996 t9 = (*
reinterpret_cast< T9*
>(data)); data +=
sizeof( T9);
17997 t10 = (*
reinterpret_cast<T10*
>(data)); data +=
sizeof(T10);
17998 t11 = (*
reinterpret_cast<T11*
>(data)); data +=
sizeof(T11);
18002 template <
typename T1,
typename T2,
typename T3,
typename T4,
18003 typename T5,
typename T6,
typename T7,
typename T8,
18004 typename T9,
typename T10>
18006 T1& t1, T2& t2, T3& t3, T4& t4,
18007 T5& t5, T6& t6, T7& t7, T8& t8,
18010 t1 = (*
reinterpret_cast< T1*
>(data)); data +=
sizeof( T1);
18011 t2 = (*
reinterpret_cast< T2*
>(data)); data +=
sizeof( T2);
18012 t3 = (*
reinterpret_cast< T3*
>(data)); data +=
sizeof( T3);
18013 t4 = (*
reinterpret_cast< T4*
>(data)); data +=
sizeof( T4);
18014 t5 = (*
reinterpret_cast< T5*
>(data)); data +=
sizeof( T5);
18015 t6 = (*
reinterpret_cast< T6*
>(data)); data +=
sizeof( T6);
18016 t7 = (*
reinterpret_cast< T7*
>(data)); data +=
sizeof( T7);
18017 t8 = (*
reinterpret_cast< T8*
>(data)); data +=
sizeof( T8);
18018 t9 = (*
reinterpret_cast< T9*
>(data)); data +=
sizeof( T9);
18019 t10 = (*
reinterpret_cast<T10*
>(data)); data +=
sizeof(T10);
18023 template <
typename T1,
typename T2,
typename T3,
typename T4,
18024 typename T5,
typename T6,
typename T7,
typename T8,
18027 T1& t1, T2& t2, T3& t3, T4& t4,
18028 T5& t5, T6& t6, T7& t7, T8& t8,
18031 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18032 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18033 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18034 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18035 t5 = (*
reinterpret_cast<T5*
>(data)); data +=
sizeof(T5);
18036 t6 = (*
reinterpret_cast<T6*
>(data)); data +=
sizeof(T6);
18037 t7 = (*
reinterpret_cast<T7*
>(data)); data +=
sizeof(T7);
18038 t8 = (*
reinterpret_cast<T8*
>(data)); data +=
sizeof(T8);
18039 t9 = (*
reinterpret_cast<T9*
>(data)); data +=
sizeof(T9);
18043 template <
typename T1,
typename T2,
typename T3,
typename T4,
18044 typename T5,
typename T6,
typename T7,
typename T8>
18046 T1& t1, T2& t2, T3& t3, T4& t4,
18047 T5& t5, T6& t6, T7& t7, T8& t8)
18049 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18050 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18051 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18052 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18053 t5 = (*
reinterpret_cast<T5*
>(data)); data +=
sizeof(T5);
18054 t6 = (*
reinterpret_cast<T6*
>(data)); data +=
sizeof(T6);
18055 t7 = (*
reinterpret_cast<T7*
>(data)); data +=
sizeof(T7);
18056 t8 = (*
reinterpret_cast<T8*
>(data)); data +=
sizeof(T8);
18060 template <
typename T1,
typename T2,
typename T3,
typename T4,
18061 typename T5,
typename T6,
typename T7>
18063 T1& t1, T2& t2, T3& t3, T4& t4,
18064 T5& t5, T6& t6, T7& t7)
18066 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18067 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18068 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18069 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18070 t5 = (*
reinterpret_cast<T5*
>(data)); data +=
sizeof(T5);
18071 t6 = (*
reinterpret_cast<T6*
>(data)); data +=
sizeof(T6);
18072 t7 = (*
reinterpret_cast<T7*
>(data)); data +=
sizeof(T7);
18076 template <
typename T1,
typename T2,
typename T3,
typename T4,
18077 typename T5,
typename T6>
18079 T1& t1, T2& t2, T3& t3, T4& t4,
18082 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18083 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18084 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18085 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18086 t5 = (*
reinterpret_cast<T5*
>(data)); data +=
sizeof(T5);
18087 t6 = (*
reinterpret_cast<T6*
>(data)); data +=
sizeof(T6);
18091 template <
typename T1,
typename T2,
typename T3,
typename T4,
18094 T1& t1, T2& t2, T3& t3, T4& t4,
18097 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18098 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18099 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18100 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18101 t5 = (*
reinterpret_cast<T5*
>(data)); data +=
sizeof(T5);
18105 template <
typename T1,
typename T2,
typename T3,
typename T4>
18107 T1& t1, T2& t2, T3& t3, T4& t4)
18109 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18110 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18111 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18112 t4 = (*
reinterpret_cast<T4*
>(data)); data +=
sizeof(T4);
18116 template <
typename T1,
typename T2,
typename T3>
18118 T1& t1, T2& t2, T3& t3)
18120 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18121 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18122 t3 = (*
reinterpret_cast<T3*
>(data)); data +=
sizeof(T3);
18126 template <
typename T1,
typename T2>
18130 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18131 t2 = (*
reinterpret_cast<T2*
>(data)); data +=
sizeof(T2);
18135 template <
typename T1>
18139 t1 = (*
reinterpret_cast<T1*
>(data)); data +=
sizeof(T1);
18143 template <
typename T, std::
size_t N>
18146 T* begin =
reinterpret_cast<T*
>(data);
18147 T* end = begin + N;
18148 std::copy(begin,end,&t[0]);
18149 return data + (N *
sizeof(
T));
18152 template <
typename T,
18153 typename Allocator,
18154 template <
typename,
typename>
class Sequence>
18156 const std::size_t& n,
18157 const Sequence<T,Allocator>& sequence)
18159 T*
ptr =
reinterpret_cast<T>(data);
18160 std::copy(ptr, ptr + n, std::back_inserter(sequence));
18161 return data + (sequence.size() *
sizeof(
T));
18164 template <
typename T,
18165 typename Comparator,
18166 typename Allocator>
18168 const std::size_t& n,
18169 const std::set<T,Comparator,Allocator>& set)
18171 T*
ptr =
reinterpret_cast<T>(data);
18173 return data + (set.size() *
sizeof(
T));
18176 template <
typename T,
18177 typename Comparator,
18178 typename Allocator>
18180 const std::size_t& n,
18181 const std::multiset<T,Comparator,Allocator>& multiset)
18183 T*
ptr =
reinterpret_cast<T>(data);
18184 std::copy(ptr, ptr + n,
std::inserter(multiset,multiset.begin()));
18185 return data + (multiset.size() *
sizeof(
T));
18188 template <
typename T1,
typename T2,
typename T3,
typename T4,
18189 typename T5,
typename T6,
typename T7,
typename T8,
18190 typename T9,
typename T10,
typename T11,
typename T12>
18192 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18193 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
18194 const T9& t9,
const T10& t10,
const T11& t11,
const T12& t12)
18196 (*
reinterpret_cast< T1*
>(data)) = t1; data +=
sizeof( T1);
18197 (*
reinterpret_cast< T2*
>(data)) = t2; data +=
sizeof( T2);
18198 (*
reinterpret_cast< T3*
>(data)) = t3; data +=
sizeof( T3);
18199 (*
reinterpret_cast< T4*
>(data)) = t4; data +=
sizeof( T4);
18200 (*
reinterpret_cast< T5*
>(data)) = t5; data +=
sizeof( T5);
18201 (*
reinterpret_cast< T6*
>(data)) = t6; data +=
sizeof( T6);
18202 (*
reinterpret_cast< T7*
>(data)) = t7; data +=
sizeof( T7);
18203 (*
reinterpret_cast< T8*
>(data)) = t8; data +=
sizeof( T8);
18204 (*
reinterpret_cast< T9*
>(data)) = t9; data +=
sizeof( T9);
18205 (*
reinterpret_cast<T10*
>(data)) = t10; data +=
sizeof(T10);
18206 (*
reinterpret_cast<T11*
>(data)) = t11; data +=
sizeof(T11);
18207 (*
reinterpret_cast<T12*
>(data)) = t12; data +=
sizeof(T12);
18211 template <
typename T1,
typename T2,
typename T3,
typename T4,
18212 typename T5,
typename T6,
typename T7,
typename T8,
18213 typename T9,
typename T10,
typename T11>
18215 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18216 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
18217 const T9& t9,
const T10& t10,
const T11& t11)
18219 (*
reinterpret_cast< T1*
>(data)) = t1; data +=
sizeof( T1);
18220 (*
reinterpret_cast< T2*
>(data)) = t2; data +=
sizeof( T2);
18221 (*
reinterpret_cast< T3*
>(data)) = t3; data +=
sizeof( T3);
18222 (*
reinterpret_cast< T4*
>(data)) = t4; data +=
sizeof( T4);
18223 (*
reinterpret_cast< T5*
>(data)) = t5; data +=
sizeof( T5);
18224 (*
reinterpret_cast< T6*
>(data)) = t6; data +=
sizeof( T6);
18225 (*
reinterpret_cast< T7*
>(data)) = t7; data +=
sizeof( T7);
18226 (*
reinterpret_cast< T8*
>(data)) = t8; data +=
sizeof( T8);
18227 (*
reinterpret_cast< T9*
>(data)) = t9; data +=
sizeof( T9);
18228 (*
reinterpret_cast<T10*
>(data)) = t10; data +=
sizeof(T10);
18229 (*
reinterpret_cast<T11*
>(data)) = t11; data +=
sizeof(T11);
18233 template <
typename T1,
typename T2,
typename T3,
typename T4,
18234 typename T5,
typename T6,
typename T7,
typename T8,
18235 typename T9,
typename T10>
18237 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18238 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
18239 const T9& t9,
const T10& t10)
18241 (*
reinterpret_cast< T1*
>(data)) = t1; data +=
sizeof( T1);
18242 (*
reinterpret_cast< T2*
>(data)) = t2; data +=
sizeof( T2);
18243 (*
reinterpret_cast< T3*
>(data)) = t3; data +=
sizeof( T3);
18244 (*
reinterpret_cast< T4*
>(data)) = t4; data +=
sizeof( T4);
18245 (*
reinterpret_cast< T5*
>(data)) = t5; data +=
sizeof( T5);
18246 (*
reinterpret_cast< T6*
>(data)) = t6; data +=
sizeof( T6);
18247 (*
reinterpret_cast< T7*
>(data)) = t7; data +=
sizeof( T7);
18248 (*
reinterpret_cast< T8*
>(data)) = t8; data +=
sizeof( T8);
18249 (*
reinterpret_cast< T9*
>(data)) = t9; data +=
sizeof( T9);
18250 (*
reinterpret_cast<T10*
>(data)) = t10; data +=
sizeof(T10);
18254 template <
typename T1,
typename T2,
typename T3,
typename T4,
18255 typename T5,
typename T6,
typename T7,
typename T8,
18258 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18259 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8,
18262 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18263 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18264 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18265 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18266 (*
reinterpret_cast<T5*
>(data)) = t5; data +=
sizeof(T5);
18267 (*
reinterpret_cast<T6*
>(data)) = t6; data +=
sizeof(T6);
18268 (*
reinterpret_cast<T7*
>(data)) = t7; data +=
sizeof(T7);
18269 (*
reinterpret_cast<T8*
>(data)) = t8; data +=
sizeof(T8);
18270 (*
reinterpret_cast<T9*
>(data)) = t9; data +=
sizeof(T9);
18274 template <
typename T1,
typename T2,
typename T3,
typename T4,
18275 typename T5,
typename T6,
typename T7,
typename T8>
18277 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18278 const T5& t5,
const T6& t6,
const T7& t7,
const T8& t8)
18280 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18281 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18282 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18283 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18284 (*
reinterpret_cast<T5*
>(data)) = t5; data +=
sizeof(T5);
18285 (*
reinterpret_cast<T6*
>(data)) = t6; data +=
sizeof(T6);
18286 (*
reinterpret_cast<T7*
>(data)) = t7; data +=
sizeof(T7);
18287 (*
reinterpret_cast<T8*
>(data)) = t8; data +=
sizeof(T8);
18291 template <
typename T1,
typename T2,
typename T3,
typename T4,
18292 typename T5,
typename T6,
typename T7>
18294 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18295 const T5& t5,
const T6& t6,
const T7& t7)
18297 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18298 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18299 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18300 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18301 (*
reinterpret_cast<T5*
>(data)) = t5; data +=
sizeof(T5);
18302 (*
reinterpret_cast<T6*
>(data)) = t6; data +=
sizeof(T6);
18303 (*
reinterpret_cast<T7*
>(data)) = t7; data +=
sizeof(T7);
18307 template <
typename T1,
typename T2,
typename T3,
typename T4,
18308 typename T5,
typename T6>
18310 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18311 const T5& t5,
const T6& t6)
18313 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18314 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18315 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18316 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18317 (*
reinterpret_cast<T5*
>(data)) = t5; data +=
sizeof(T5);
18318 (*
reinterpret_cast<T6*
>(data)) = t6; data +=
sizeof(T6);
18322 template <
typename T1,
typename T2,
typename T3,
typename T4,
18325 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4,
18328 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18329 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18330 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18331 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18332 (*
reinterpret_cast<T5*
>(data)) = t5; data +=
sizeof(T5);
18336 template <
typename T1,
typename T2,
typename T3,
typename T4>
18338 const T1& t1,
const T2& t2,
const T3& t3,
const T4& t4)
18340 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18341 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18342 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18343 (*
reinterpret_cast<T4*
>(data)) = t4; data +=
sizeof(T4);
18347 template <
typename T1,
typename T2,
typename T3>
18349 const T1& t1,
const T2& t2,
const T3& t3)
18351 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18352 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18353 (*
reinterpret_cast<T3*
>(data)) = t3; data +=
sizeof(T3);
18357 template <
typename T1,
typename T2>
18359 const T1& t1,
const T2& t2)
18361 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18362 (*
reinterpret_cast<T2*
>(data)) = t2; data +=
sizeof(T2);
18366 template <
typename T1>
18370 (*
reinterpret_cast<T1*
>(data)) = t1; data +=
sizeof(T1);
18374 template <
typename T, std::
size_t N>
18375 inline unsigned char*
write_pod(
unsigned char* data,
const T (&t)[N])
18377 T*
ptr =
reinterpret_cast<T*
>(data);
18378 std::copy(t,t + N,ptr);
18379 return data + (N *
sizeof(
T));
18382 template <
typename T,
18383 typename Allocator,
18384 template <
typename,
typename>
class Sequence>
18386 const Sequence<T,Allocator>& sequence)
18388 T*
ptr =
reinterpret_cast<T>(data);
18389 std::copy(sequence.begin(),sequence.end(),
ptr);
18390 return data + (sequence.size() *
sizeof(
T));
18393 template <
typename T,
18394 typename Comparator,
18395 typename Allocator>
18397 const std::set<T,Comparator,Allocator>& set)
18399 T*
ptr =
reinterpret_cast<T>(data);
18400 std::copy(set.begin(),set.end(),
ptr);
18401 return data + (set.size() *
sizeof(
T));
18404 template <
typename T,
18405 typename Comparator,
18406 typename Allocator>
18408 const std::multiset<T,Comparator,Allocator>& multiset)
18410 T*
ptr =
reinterpret_cast<T>(data);
18411 std::copy(multiset.begin(),multiset.end(),
ptr);
18412 return data + (multiset.size() *
sizeof(
T));
18419 typedef const unsigned char* itr_type;
18421 inline bool condition_equal(
const itr_type begin,
const itr_type end)
const
18423 if (s.size() ==
static_cast<std::size_t
>(
std::distance(begin,end)))
18425 return std::equal(s_begin,s_end,begin);
18431 inline bool condition_notequal(
const itr_type begin,
const itr_type end)
const
18433 if (s.size() ==
static_cast<std::size_t
>(
std::distance(begin,end)))
18435 return !std::equal(s_begin,s_end,begin);
18441 inline bool condition_like(
const itr_type begin,
const itr_type end)
const
18443 return match(s_begin,s_end,begin,end,(
unsigned char)
'*',(
unsigned char)
'?');
18446 inline bool condition_begins_with(
const itr_type begin,
const itr_type end)
const
18448 if (s.size() ==
static_cast<std::size_t
>(
std::distance(begin,end)))
18456 inline bool condition_ends_with(
const itr_type begin,
const itr_type end)
const
18458 if (s.size() ==
static_cast<std::size_t
>(
std::distance(begin,end)))
18466 inline bool condition_within(
const itr_type begin,
const itr_type end)
const
18468 if (s.size() <=
static_cast<std::size_t
>(
std::distance(begin,end)))
18470 return (end != std::search(begin,end,s_begin,s_end));
18476 inline bool condition_notwithin(
const itr_type begin,
const itr_type end)
const
18478 if (s.size() <=
static_cast<std::size_t
>(
std::distance(begin,end)))
18480 return (end == std::search(begin,end,s_begin,s_end));
18486 typedef bool (
string_condition::*condition_method)(
const itr_type begin,
const itr_type end)
const;
18502 : cond_type_(cond_type),
18504 s_begin(reinterpret_cast<const unsigned char*>(s.data())),
18505 s_end(reinterpret_cast<const unsigned char*>(s.data() + str.size())),
18506 condition_method_(0)
18508 switch (cond_type_)
18510 case equal : condition_method_ = &string_condition::condition_equal;
18512 case notequal : condition_method_ = &string_condition::condition_notequal;
18514 case like : condition_method_ = &string_condition::condition_like;
18516 case begins_with : condition_method_ = &string_condition::condition_begins_with;
18518 case ends_with : condition_method_ = &string_condition::condition_ends_with;
18520 case within : condition_method_ = &string_condition::condition_within;
18522 case notwithin : condition_method_ = &string_condition::condition_notwithin;
18527 template <
typename Iterator>
18530 return ((*this).*condition_method_)(begin,end);
18535 return operator()(reinterpret_cast<const unsigned char*>(str.data()),
18536 reinterpret_cast<const unsigned char*>(str.data() + str.size()));
18541 condition_type cond_type_;
18543 const unsigned char* s_begin;
18544 const unsigned char* s_end;
18545 condition_method condition_method_;
18550 template <
typename KeyIterator,
typename ValueType>
18554 template <
typename Iterator,
18556 typename KeyValue =
typename std::iterator_traits<Iterator>::value_type>
18564 typedef node<Iterator,Value,KeyValue>
node_t;
18566 typedef const node_ptr const_node_ptr;
18568 typedef std::vector<node_ptr> node_list_t;
18569 typedef typename node_list_t::const_iterator node_list_iterator;
18572 : key_value_(key_value),
18573 value_holder_(
false)
18577 : key_value_(key_value),
18578 value_holder_(
true),
18584 if (!node_list_.empty())
18586 node_list_iterator itr = node_list_.begin();
18587 node_list_iterator end = node_list_.end();
18598 if (node_list_.empty())
18600 node_list_iterator itr = node_list_.begin();
18601 const node_list_iterator end = node_list_.end();
18604 if (key_value == (*itr)->key_value_)
18612 inline void assign_value(
const value_t& v)
18615 value_holder_ =
true;
18620 node_list_.push_back(n);
18623 inline bool value_holder()
const
18625 return value_holder_;
18628 inline const value_t& value()
const
18644 bool value_holder_;
18646 node_list_t node_list_;
18652 typedef typename std::iterator_traits<KeyIterator>::value_type
key_value_t;
18662 template <
typename key_iterator_t>
18664 const key_iterator_t end,
18670 key_iterator_t itr = begin;
18679 if (0 == (next_node = n->get_node(key)))
18681 n->add_node(next_node =
new node_t(key));
18688 parent->assign_value(v);
18691 template <
typename key_iterator_t>
18692 inline bool find(
const key_iterator_t begin,
18693 const key_iterator_t end,
18698 key_iterator_t itr = begin;
18703 node_ptr next_node = n->get_node(*itr);
18704 if (0 == next_node)
18710 if (!parent->value_holder())
18712 v = parent->value();
18716 template <
typename key_iterator_t>
18717 inline bool find_prefix(
const key_iterator_t begin,
const key_iterator_t end)
const
18722 key_iterator_t itr = begin;
18727 if (0 == (n = n->get_node(*itr)))
18745 template <
typename Value>
18748 const Value& value = Value(0))
18750 trie.
insert(key.begin(),key.end(),value);
18753 template <
typename Value>
18756 const Value& value = Value(0))
18761 template <
typename Value>
18766 return trie.
find(key.begin(),key.end(),v);
18769 template <
typename Value>
18777 template <
typename Value>
18784 template <
typename Value>
18793 template <
typename ValueType,
typename KeyIterator = std::
string::const_iterator>
18807 static const std::size_t bits_per_char = 0x08;
18808 static const unsigned char bit_mask[bits_per_char] = {
18825 maximum_size(std::numeric_limits<unsigned long long int>::max()),
18826 minimum_number_of_hashes(1),
18827 maximum_number_of_hashes(std::numeric_limits<unsigned int>::max()),
18828 projected_element_count(10000),
18829 false_positive_probability(1.0 / projected_element_count),
18830 random_seed(0xA5A5A5A55A5A5A5AULL)
18838 return (minimum_size > maximum_size) ||
18839 (minimum_number_of_hashes > maximum_number_of_hashes) ||
18840 (minimum_number_of_hashes < 1) ||
18841 (0 == maximum_number_of_hashes) ||
18842 (0 == projected_element_count) ||
18843 (false_positive_probability < 0.0) ||
18844 (std::numeric_limits<double>::infinity() == std::abs(false_positive_probability)) ||
18845 (0 == random_seed) ||
18846 (0xFFFFFFFFFFFFFFFFULL == random_seed);
18871 return reader(minimum_size) &&
18872 reader(maximum_size) &&
18873 reader(minimum_number_of_hashes) &&
18874 reader(maximum_number_of_hashes) &&
18875 reader(projected_element_count) &&
18876 reader(false_positive_probability) &&
18877 reader(random_seed);
18882 return writer(minimum_size) &&
18883 writer(maximum_size) &&
18884 writer(minimum_number_of_hashes) &&
18885 writer(maximum_number_of_hashes) &&
18886 writer(projected_element_count) &&
18887 writer(false_positive_probability) &&
18888 writer(random_seed);
18894 : number_of_hashes(0),
18917 double min_m = std::numeric_limits<double>::infinity();
18918 double min_k = 0.0;
18919 double curr_m = 0.0;
18924 double numerator = -k * projected_element_count;
18925 double denominator = std::log(1.0 - std::pow(false_positive_probability, 1.0 / k));
18926 curr_m = numerator / denominator;
18927 if (curr_m < min_m)
18938 optp.
table_size =
static_cast<unsigned long long int>(min_m);
18969 raw_table_size_(0),
18970 projected_element_count_(0),
18971 inserted_element_count_(0),
18973 desired_false_positive_probability_(0.0)
18978 projected_element_count_(p.projected_element_count),
18979 inserted_element_count_(0),
18980 random_seed_((p.random_seed * 0xA5A5A5A5) + 1),
18981 desired_false_positive_probability_(p.false_positive_probability)
18985 generate_unique_salt();
18986 raw_table_size_ = table_size_ / bits_per_char;
18987 bit_table_ =
new cell_type[
static_cast<std::size_t
>(raw_table_size_)];
18988 std::fill_n(bit_table_,raw_table_size_,0x00);
18993 this->operator=(filter);
19008 (salt_ == f.
salt_) &&
19031 delete[] bit_table_;
19032 bit_table_ =
new cell_type[
static_cast<std::size_t
>(raw_table_size_)];
19041 delete[] bit_table_;
19046 return (0 == table_size_);
19051 std::fill_n(bit_table_,raw_table_size_,0x00);
19052 inserted_element_count_ = 0;
19055 inline void insert(
const unsigned char* key_begin,
const std::size_t& length)
19057 std::size_t bit_index = 0;
19058 std::size_t bit = 0;
19059 for (std::size_t i = 0; i < salt_.size(); ++i)
19061 compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
19062 bit_table_[bit_index / bits_per_char] |= bit_mask[bit];
19064 ++inserted_element_count_;
19067 template <
typename T>
19071 insert(reinterpret_cast<const unsigned char*>(&t),
sizeof(
T));
19076 insert(reinterpret_cast<const unsigned char*>(key.data()),key.size());
19079 inline void insert(
const char* data,
const std::size_t& length)
19081 insert(reinterpret_cast<const unsigned char*>(data),length);
19084 template <
typename InputIterator>
19085 inline void insert(
const InputIterator begin,
const InputIterator end)
19087 InputIterator itr = begin;
19094 inline virtual bool contains(
const unsigned char* key_begin,
const std::size_t length)
const
19096 std::size_t bit_index = 0;
19097 std::size_t bit = 0;
19098 for (std::size_t i = 0; i < salt_.size(); ++i)
19100 compute_indices(hash_ap(key_begin,length,salt_[i]),bit_index,bit);
19101 if ((bit_table_[bit_index / bits_per_char] & bit_mask[bit]) != bit_mask[bit])
19109 template <
typename T>
19112 return contains(reinterpret_cast<const unsigned char*>(&t),static_cast<std::size_t>(
sizeof(
T)));
19117 return contains(reinterpret_cast<const unsigned char*>(key.data()),key.size());
19120 inline bool contains(
const char* data,
const std::size_t& length)
const
19122 return contains(reinterpret_cast<const unsigned char*>(data),length);
19125 template <
typename InputIterator>
19126 inline InputIterator
contains_all(
const InputIterator begin,
const InputIterator end)
const
19128 InputIterator itr = begin;
19131 if (!contains(*itr))
19140 template <
typename InputIterator>
19141 inline InputIterator
contains_none(
const InputIterator begin,
const InputIterator end)
const
19143 InputIterator itr = begin;
19146 if (contains(*itr))
19155 inline virtual unsigned long long int size()
const
19157 return table_size_;
19162 return inserted_element_count_;
19174 return std::pow(1.0 - std::exp(-1.0 * salt_.size() * inserted_element_count_ / size()), 1.0 * salt_.size());
19186 for (std::size_t i = 0; i < raw_table_size_; ++i)
19203 for (std::size_t i = 0; i < raw_table_size_; ++i)
19220 for (std::size_t i = 0; i < raw_table_size_; ++i)
19235 if (0 == table_size_)
19237 const std::size_t buffer_size =
sizeof( salt_count_) +
19238 sizeof( table_size_) +
19239 sizeof( raw_table_size_) +
19240 sizeof( projected_element_count_) +
19241 sizeof( inserted_element_count_) +
19242 sizeof( random_seed_) +
19243 sizeof(desired_false_positive_probability_) +
19245 static_cast<std::size_t
>(raw_table_size_) *
19248 std::ofstream ostream(file_name.c_str(),std::ios::binary);
19251 unsigned char* buffer =
new unsigned char[buffer_size];
19253 writer.
reset(
true);
19254 bool result = writer(salt_count_) &&
19255 writer(table_size_) &&
19256 writer(raw_table_size_) &&
19257 writer(projected_element_count_) &&
19258 writer(inserted_element_count_) &&
19259 writer(random_seed_) &&
19260 writer(desired_false_positive_probability_) &&
19262 writer(bit_table_,raw_table_size_);
19274 std::ifstream istream(file_name.c_str(),std::ios::binary);
19279 raw_table_size_ = 0;
19280 projected_element_count_ = 0;
19281 inserted_element_count_ = 0;
19283 desired_false_positive_probability_ = 0.0;
19285 if (0 != bit_table_)
19286 delete [] bit_table_;
19289 unsigned char* buffer =
new unsigned char[buffer_size];
19291 reader.
reset(
true);
19292 reader(istream,buffer_size);
19294 bool result = reader(salt_count_) &&
19295 reader(table_size_) &&
19296 reader(raw_table_size_) &&
19297 reader(projected_element_count_) &&
19298 reader(inserted_element_count_) &&
19299 reader(random_seed_) &&
19300 reader(desired_false_positive_probability_) &&
19302 reader(bit_table_,raw_table_size_);
19309 return salt_.size();
19316 bit_index =
static_cast<std::size_t
>(hash % table_size_);
19317 bit = bit_index % bits_per_char;
19328 const unsigned int predef_salt_count = 128;
19329 static const bloom_type predef_salt[predef_salt_count] =
19331 0xAAAAAAAA, 0x55555555, 0x33333333, 0xCCCCCCCC,
19332 0x66666666, 0x99999999, 0xB5B5B5B5, 0x4B4B4B4B,
19333 0xAA55AA55, 0x55335533, 0x33CC33CC, 0xCC66CC66,
19334 0x66996699, 0x99B599B5, 0xB54BB54B, 0x4BAA4BAA,
19335 0xAA33AA33, 0x55CC55CC, 0x33663366, 0xCC99CC99,
19336 0x66B566B5, 0x994B994B, 0xB5AAB5AA, 0xAAAAAA33,
19337 0x555555CC, 0x33333366, 0xCCCCCC99, 0x666666B5,
19338 0x9999994B, 0xB5B5B5AA, 0xFFFFFFFF, 0xFFFF0000,
19339 0xB823D5EB, 0xC1191CDF, 0xF623AEB3, 0xDB58499F,
19340 0xC8D42E70, 0xB173F616, 0xA91A5967, 0xDA427D63,
19341 0xB1E8A2EA, 0xF6C0D155, 0x4909FEA3, 0xA68CC6A7,
19342 0xC395E782, 0xA26057EB, 0x0CD5DA28, 0x467C5492,
19343 0xF15E6982, 0x61C6FAD3, 0x9615E352, 0x6E9E355A,
19344 0x689B563E, 0x0C9831A8, 0x6753C18B, 0xA622689B,
19345 0x8CA63C47, 0x42CC2884, 0x8E89919B, 0x6EDBD7D3,
19346 0x15B6796C, 0x1D6FDFE4, 0x63FF9092, 0xE7401432,
19347 0xEFFE9412, 0xAEAEDF79, 0x9F245A31, 0x83C136FC,
19348 0xC3DA4A8C, 0xA5112C8C, 0x5271F491, 0x9A948DAB,
19349 0xCEE59A8D, 0xB5F525AB, 0x59D13217, 0x24E7C331,
19350 0x697C2103, 0x84B0A460, 0x86156DA9, 0xAEF2AC68,
19351 0x23243DA5, 0x3F649643, 0x5FA495A8, 0x67710DF8,
19352 0x9A6C499E, 0xDCFB0227, 0x46A43433, 0x1832B07A,
19353 0xC46AFF3C, 0xB9C8FFF0, 0xC9500467, 0x34431BDF,
19354 0xB652432B, 0xE367F12B, 0x427F4C1B, 0x224C006E,
19355 0x2E7E5A89, 0x96F99AA5, 0x0BEB452A, 0x2FD87C39,
19356 0x74B2E1FB, 0x222EFD24, 0xF357F60C, 0x440FCB1E,
19357 0x8BBE030F, 0x6704DC29, 0x1144D12F, 0x948B1355,
19358 0x6D8FD7E9, 0x1C11A014, 0xADD1592F, 0xFB3C712E,
19359 0xFC77642F, 0xF9C4CE8C, 0x31312FB9, 0x08B0DD79,
19360 0x318FA6E7, 0xC040D23D, 0xC0589AA7, 0x0CA5C075,
19361 0xF874B172, 0x0CF914D5, 0x784D3280, 0x4E8CFEBC,
19362 0xC569F575, 0xCDB2A091, 0x2CC016B4, 0x5C5F4421
19365 if (salt_count_ <= predef_salt_count)
19367 std::copy(predef_salt,
19368 predef_salt + salt_count_,
19369 std::back_inserter(salt_));
19370 for (
unsigned int i = 0; i < salt_.size(); ++i)
19378 salt_[i] = salt_[i] * salt_[(i + 3) % salt_.size()] +
static_cast<bloom_type>(random_seed_);
19383 std::copy(predef_salt,predef_salt + predef_salt_count,std::back_inserter(salt_));
19384 srand(static_cast<unsigned int>(random_seed_));
19385 while (salt_.size() < salt_count_)
19388 if (0 == current_salt)
continue;
19389 if (salt_.end() ==
std::find(salt_.begin(), salt_.end(), current_salt))
19391 salt_.push_back(current_salt);
19399 const unsigned char* itr = begin;
19400 unsigned int loop = 0;
19401 while (remaining_length >= 8)
19403 const unsigned int& i1 = *(
reinterpret_cast<const unsigned int*
>(itr)); itr +=
sizeof(
unsigned int);
19404 const unsigned int& i2 = *(
reinterpret_cast<const unsigned int*
>(itr)); itr +=
sizeof(
unsigned int);
19405 hash ^= (hash << 7) ^ i1 * (hash >> 3) ^
19406 (~((hash << 11) + (i2 ^ (hash >> 5))));
19407 remaining_length -= 8;
19409 while (remaining_length >= 4)
19411 const unsigned int& i = *(
reinterpret_cast<const unsigned int*
>(itr));
19413 hash ^= (hash << 7) ^ i * (hash >> 3);
19415 hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
19417 remaining_length -= 4;
19418 itr +=
sizeof(
unsigned int);
19420 while (remaining_length >= 2)
19422 const unsigned short& i = *(
reinterpret_cast<const unsigned short*
>(itr));
19424 hash ^= (hash << 7) ^ i * (hash >> 3);
19426 hash ^= (~((hash << 11) + (i ^ (hash >> 5))));
19428 remaining_length -= 2;
19429 itr +=
sizeof(
unsigned short);
19431 if (remaining_length)
19432 hash += ((*itr) ^ (hash * 0x5A5A5A5A));
19434 hash += ((hash + 1) * 0x5A5A5A5A);
19477 size_list.push_back(table_size_);
19480 inline virtual unsigned long long int size()
const
19482 return size_list.back();
19487 if ((0.0 >= percentage) || (percentage >= 100.0))
19492 unsigned long long int original_table_size = size_list.back();
19493 unsigned long long int new_table_size =
static_cast<unsigned long long int>((size_list.back() * (1.0 - (percentage / 100.0))));
19494 new_table_size -= (((new_table_size % bits_per_char) != 0) ? (new_table_size % bits_per_char) : 0);
19496 if ((bits_per_char > new_table_size) || (new_table_size >= original_table_size))
19501 desired_false_positive_probability_ = effective_fpp();
19502 cell_type* tmp =
new cell_type[
static_cast<std::size_t
>(new_table_size / bits_per_char)];
19503 std::copy(bit_table_, bit_table_ + (new_table_size / bits_per_char), tmp);
19504 cell_type* itr = bit_table_ + (new_table_size / bits_per_char);
19505 cell_type* end = bit_table_ + (original_table_size / bits_per_char);
19510 *(itr_tmp++) |= (*itr++);
19513 delete[] bit_table_;
19515 size_list.push_back(new_table_size);
19522 inline virtual void compute_indices(
const bloom_type&
hash, std::size_t& bit_index, std::size_t& bit)
const
19525 for (std::size_t i = 0; i < size_list.size(); ++i)
19527 bit_index %= size_list[i];
19529 bit = bit_index % bits_per_char;
19532 std::vector<unsigned long long int> size_list;
19542 hash ^= ((hash << 7) ^ data[0] * (hash >> 3));
19543 hash ^= ~((hash << 11) + (data[1] ^ (hash >> 5)));
19548 hash ^= ((hash << 7) ^ data[0] * (hash >> 3));
19549 hash ^= ~((hash << 11) + (data[1] ^ (hash >> 5)));
19554 const unsigned char* itr =
reinterpret_cast<const unsigned char*
>(&data);
19555 hash ^= ((hash << 7) ^ itr[0] * (hash >> 3));
19556 hash ^= ~((hash << 11) + (itr[1] ^ (hash >> 5)));
19557 hash ^= ((hash << 7) ^ itr[2] * (hash >> 3));
19558 hash ^= ~((hash << 11) + (itr[3] ^ (hash >> 5)));
19568 const unsigned char* itr =
reinterpret_cast<const unsigned char*
>(&data);
19569 hash ^= ((hash << 7) ^ itr[0] * (hash >> 3));
19570 hash ^= ~((hash << 11) + (itr[1] ^ (hash >> 5)));
19571 hash ^= ((hash << 7) ^ itr[2] * (hash >> 3));
19572 hash ^= ~((hash << 11) + (itr[3] ^ (hash >> 5)));
19573 hash ^= ((hash << 7) ^ itr[4] * (hash >> 3));
19574 hash ^= ~((hash << 11) + (itr[5] ^ (hash >> 5)));
19575 hash ^= ((hash << 7) ^ itr[6] * (hash >> 3));
19576 hash ^= ~((hash << 11) + (itr[7] ^ (hash >> 5)));
19581 const unsigned char* itr =
reinterpret_cast<const unsigned char*
>(&data);
19582 hash ^= ((hash << 7) ^ itr[0] * (hash >> 3));
19583 hash ^= ~((hash << 11) + (itr[1] ^ (hash >> 5)));
19584 hash ^= ((hash << 7) ^ itr[2] * (hash >> 3));
19585 hash ^= ~((hash << 11) + (itr[3] ^ (hash >> 5)));
19586 hash ^= ((hash << 7) ^ itr[4] * (hash >> 3));
19587 hash ^= ~((hash << 11) + (itr[5] ^ (hash >> 5)));
19588 hash ^= ((hash << 7) ^ itr[6] * (hash >> 3));
19589 hash ^= ~((hash << 11) + (itr[7] ^ (hash >> 5)));
19592 template <std::
size_t block_size,
typename Iterator>
19595 while (length >= block_size)
19597 for (std::size_t i = 0; i < block_size; ++i, ++itr)
19601 length -= block_size;
19605 template <std::
size_t block_size>
19608 unsigned int local_hash =
hash;
19609 while (length >= block_size)
19611 for (std::size_t i = 0; i < block_size; ++i, ++itr)
19615 length -= block_size;
19620 template <std::
size_t block_size>
19623 compute_block<block_size>(
reinterpret_cast<unsigned char*
>(itr),length,hash);
19626 static const unsigned int hash_seed = 0xAAAAAAAA;
19628 template <
typename Iterator>
19629 inline void hash(
const Iterator itr, std::size_t length,
unsigned int& hash_value)
19631 if (length >= 64) compute_block<64>(itr,length,hash_value);
19632 if (length >= 32) compute_block<32>(itr,length,hash_value);
19633 if (length >= 16) compute_block<16>(itr,length,hash_value);
19634 if (length >= 8) compute_block< 8>(itr,length,hash_value);
19635 if (length >= 4) compute_block< 4>(itr,length,hash_value);
19636 if (length >= 2) compute_block< 2>(itr,length,hash_value);
19637 if (length == 0) compute_block< 1>(itr,length,hash_value);
19642 template <
typename Iterator>
19643 inline unsigned int hash(
const Iterator itr,
19644 std::size_t length,
19645 unsigned int seed = details::hash_seed)
19647 unsigned int hash_value = seed;
19654 unsigned int hash_value = seed;
19655 return hash(s.begin(),s.size(),hash_value);
19658 template <
typename T,
19659 typename Allocator,
19660 template <
typename,
typename>
class Sequence>
19661 inline unsigned int hash(
const Sequence<T,Allocator>& sequence,
unsigned int seed = details::hash_seed)
19663 unsigned int hash_value = seed;
19664 return hash(sequence.begin(),sequence.size(),hash_value);
19669 template <
typename T>
19675 : restore_(restore),
19684 reference_ = copy_;
19700 template <
typename T>
19706 : initialised_(false)
19724 return initialised_ && (t_ == t);
19727 template <
typename TConvertibleType>
19743 inline operator T()
const
19755 return initialised_;
19760 return initialised_;
19765 return (initialised_ && (t_ != prev_t_));
19790 inline void assign(
const T& t)
19793 initialised_ =
true;
19803 return attrib.
value() == s;
19808 return !(s == attrib.
value());
19811 template <
typename T>
19812 static inline std::ostream& operator<<(std::ostream& os, const attribute<T>& attrib)
19814 return (os << attrib.value());
19821 class function_holder_base
19825 typedef const unsigned char* itr_type;
19827 virtual ~function_holder_base(){}
19829 virtual bool operator()(itr_type begin, itr_type end)
const = 0;
19831 inline bool operator()(
const char* begin,
const char* end)
const
19833 return operator()(reinterpret_cast<itr_type>(begin),
19834 reinterpret_cast<itr_type>(end));
19837 template <
typename Iterator>
19838 inline bool operator()(
const std::pair<Iterator,Iterator>& p)
const
19840 return operator()(p.first,p.second);
19844 template <
typename Function>
19845 class function_holder :
public function_holder_base
19849 explicit function_holder(Function&
f)
19853 inline virtual bool operator()(itr_type begin, itr_type end)
const
19855 return (*function_)(begin,end);
19860 Function* function_;
19866 : function_holder_(0)
19868 std::fill_n(function_holder_buffer_,
sizeof(function_holder_buffer_),0x00);
19871 template <
typename Function>
19874 std::fill_n(function_holder_buffer_,
sizeof(function_holder_buffer_),0x00);
19880 return (0 == function_holder_);
19885 return (0 != function_holder_) &&
19886 (0 != sa.function_holder_) &&
19887 (function_holder_ == sa.function_holder_);
19890 template <
typename InputIterator>
19893 if (0 != function_holder_)
19894 return (*function_holder_).operator()(begin,end);
19899 template <
typename InputIterator>
19900 inline bool operator()(
const std::pair<InputIterator,InputIterator>& r)
const
19902 return operator()(r.first,r.second);
19907 return operator()(s.data(),s.data() + s.size());
19910 template <
typename Function>
19913 static const std::size_t type_size =
sizeof(function_holder<Function>(
f));
19924 typedef function_holder_base* function_holder_ptr;
19928 template <
typename Function,
bool b>
19931 inline static function_holder_ptr
type(Function&,
unsigned char*)
19933 return reinterpret_cast<function_holder_ptr
>(0);
19937 template <
typename Function>
19940 inline static function_holder_ptr
type(Function&
f,
unsigned char* buffer)
19942 return new(buffer)function_holder<Function>(f);
19946 function_holder_ptr function_holder_;
19947 enum { function_holder_buffer_size = 64 };
19948 unsigned char function_holder_buffer_[function_holder_buffer_size];
19951 template <
typename Function>
19961 #define strtk_register_attribute_type_tag(T)\
19962 template<> struct supported_conversion_to_type< strtk::util::attribute<T> >{ typedef attribute_type_tag type; };\
19963 template<> struct supported_conversion_from_type< strtk::util::attribute<T> > { typedef attribute_type_tag type; };
19981 template <typename Iterator, typename
T>
19986 result.initialised() =
true;
19993 template <
typename T>
20001 #undef strtk_register_attribute_type_tag
20006 template <
typename Iterator>
20009 return result(itr,end);
20014 static std::string result_str =
"semantic_action";
20015 result = result_str;
20027 class type_holder_base
20031 typedef const unsigned char* itr_type;
20033 virtual ~type_holder_base(){}
20035 virtual bool operator()(itr_type begin, itr_type end)
const = 0;
20037 virtual bool to_string(
std::string& s)
const = 0;
20039 inline bool operator()(
const char* begin,
const char* end)
const
20041 return operator()(reinterpret_cast<itr_type>(begin),
20042 reinterpret_cast<itr_type>(end));
20045 template <
typename Iterator>
20046 inline bool operator()(
const std::pair<Iterator,Iterator>& p)
const
20048 return operator()(p.first,p.second);
20052 template <
typename T>
20053 class type_holder :
public type_holder_base
20057 typedef T* type_ptr;
20059 explicit type_holder(
T& t)
20063 inline virtual bool operator()(itr_type begin, itr_type end)
const
20068 inline virtual bool to_string(
std::string& s)
const
20073 inline operator T()
const
20075 return (*value_ptr_);
20080 type_ptr value_ptr_;
20088 std::fill_n(type_holder_buffer_,
sizeof(type_holder_buffer_),0x00);
20091 template <
typename T>
20094 std::fill_n(type_holder_buffer_,
sizeof(type_holder_buffer_),0x00);
20100 return (0 == type_holder_);
20105 return (0 != type_holder_) &&
20106 (0 != v.type_holder_) &&
20107 (type_holder_ == v.type_holder_);
20114 if (0 != v.type_holder_)
20116 std::copy(v.type_holder_buffer_,
20117 v.type_holder_buffer_ + type_holder_buffer_size,
20118 type_holder_buffer_);
20119 type_holder_ =
reinterpret_cast<type_holder_base*
>(type_holder_buffer_);
20125 template <
typename InputIterator>
20128 if (0 != type_holder_)
20129 return (*type_holder_).operator()(begin,end);
20134 template <
typename InputIterator>
20135 inline bool operator()(
const std::pair<InputIterator,InputIterator>& r)
const
20137 return operator()(r.first,r.second);
20142 return operator()(s.data(),s.data() + s.size());
20145 template <
typename T>
20148 static const std::size_t type_size =
sizeof(type_holder<T>(t));
20154 if (0 != type_holder_)
20155 return (*type_holder_).to_string(s);
20160 template <
typename T>
20161 inline operator T()
const
20163 if (0 != type_holder_)
20164 return (*type_holder_);
20171 typedef type_holder_base* type_holder_ptr;
20173 template <
typename T,
bool b>
20176 inline static type_holder_ptr
type(
T&,
unsigned char*)
20178 return reinterpret_cast<type_holder_ptr
>(0);
20182 template <
typename T>
20185 inline static type_holder_ptr
type(
T& t,
unsigned char* buffer)
20187 return new(buffer)type_holder<T>(t);
20191 type_holder_ptr type_holder_;
20192 enum { type_holder_buffer_size = 2 *
sizeof(type_holder<unsigned long long int>) };
20193 unsigned char type_holder_buffer_[type_holder_buffer_size];
20196 template <
typename Key,
20198 typename Comparator,
20199 typename MapAllocator,
20200 typename OutputIterator>
20202 OutputIterator out)
20204 if (map.empty())
return;
20205 typedef typename std::map<Key,T,Comparator,MapAllocator> map_type;
20206 typename map_type::const_iterator itr = map.begin();
20207 typename map_type::const_iterator end = map.end();
20210 *out++ = (itr++)->first;
20214 template <
typename Key,
20216 typename Comparator,
20217 typename MapAllocator,
20218 typename SetAllocator>
20220 std::set<Key,Comparator,SetAllocator>& set)
20225 template <
typename Key,
20227 typename Comparator,
20228 typename MapAllocator,
20229 typename SetAllocator>
20231 std::multiset<Key,Comparator,SetAllocator>& multiset)
20236 template <
typename Key,
20238 typename Comparator,
20239 typename MapAllocator,
20240 typename SequenceAllocator,
20241 template <
typename,
typename>
class Sequence>
20243 Sequence<Key,SequenceAllocator>& sequence)
20248 template <
typename Key,
20250 typename Comparator,
20251 typename MapAllocator,
20252 typename OutputIterator>
20255 OutputIterator out)
20257 if (map.empty())
return;
20258 typedef typename std::multimap<Key,T,Comparator,MapAllocator> map_type;
20259 typename map_type::const_iterator itr = map.find(key);
20260 typename map_type::const_iterator end = map.end();
20261 while ((end != itr) && (key == itr->first))
20263 *out++ = (itr++)->second;
20267 template <
typename Key,
20269 typename Comparator,
20270 typename MapAllocator,
20271 typename SequenceAllocator,
20272 template <
typename,
typename>
class Sequence>
20275 Sequence<T,SequenceAllocator>& sequence)
20280 template <
typename T,
20281 typename Allocator,
20282 template <
typename,
typename>
class Sequence>
20285 typename Sequence<T*,Allocator>::iterator itr = sequence.begin();
20286 typename Sequence<T*,Allocator>::iterator end = sequence.end();
20295 template <
typename Key,
20297 typename Comparator,
20298 typename Allocator>
20301 typename std::map<Key,T*,Comparator,Allocator>::iterator itr = cont.begin();
20302 typename std::map<Key,T*,Comparator,Allocator>::iterator end = cont.end();
20305 delete (*itr).second;
20311 template <
typename Key,
20313 typename Comparator,
20314 typename Allocator>
20315 inline void delete_all(std::multimap<Key,T*,Comparator,Allocator>& cont)
20317 typename std::multimap<Key,T*,Comparator,Allocator>::iterator itr = cont.begin();
20318 typename std::multimap<Key,T*,Comparator,Allocator>::iterator end = cont.end();
20321 delete (*itr).second;
20327 template <
typename T,
20328 typename Comparator,
20329 typename Allocator>
20332 typename std::set<T*,Comparator,Allocator>::iterator itr = cont.begin();
20333 typename std::set<T*,Comparator,Allocator>::iterator end = cont.end();
20342 template <
typename T,
20343 typename Comparator,
20344 typename Allocator>
20347 typename std::multiset<T*,Comparator,Allocator>::iterator itr = cont.begin();
20348 typename std::multiset<T*,Comparator,Allocator>::iterator end = cont.end();
20357 template <
typename Predicate,
20359 typename Allocator,
20360 template <
typename,
typename>
class Sequence>
20362 Sequence<T*,Allocator>& sequence)
20364 typename Sequence<T*,Allocator>::iterator itr = sequence.begin();
20365 while (sequence.end() != itr)
20370 itr = sequence.erase(itr);
20377 template <
typename Predicate,
20380 typename Comparator,
20381 typename Allocator>
20383 std::map<Key,T*,Comparator,Allocator>& cont)
20385 typename std::map<Key,T*,Comparator,Allocator>::iterator itr = cont.begin();
20386 while (cont.end() != itr)
20390 delete (*itr).second;
20391 itr = cont.erase(itr);
20398 template <
typename Predicate,
20401 typename Comparator,
20402 typename Allocator>
20404 std::multimap<Key,T*,Comparator,Allocator>& cont)
20406 typename std::multimap<Key,T*,Comparator,Allocator>::iterator itr = cont.begin();
20407 while (cont.end() != itr)
20411 delete (*itr).second;
20412 itr = cont.erase(itr);
20419 template <
typename Predicate,
20421 typename Comparator,
20422 typename Allocator>
20424 std::set<T*,Comparator,Allocator>& cont)
20426 typename std::set<T*,Comparator,Allocator>::iterator itr = cont.begin();
20427 while (cont.end() != itr)
20431 delete (*itr).second;
20432 itr = cont.erase(itr);
20439 template <
typename Predicate,
20441 typename Comparator,
20442 typename Allocator>
20444 std::multiset<T*,Comparator,Allocator>& cont)
20446 typename std::multiset<T*,Comparator,Allocator>::iterator itr = cont.begin();
20447 while (cont.end() != itr)
20451 delete (*itr).second;
20452 itr = cont.erase(itr);
20459 template <
typename T,
20460 typename Allocator,
20461 template <
typename,
typename>
class Sequence>
20463 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20464 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20465 const T& v9,
const T& v10,
const T& v11)
20467 sequence.push_back(v1); sequence.push_back(v2);
20468 sequence.push_back(v3); sequence.push_back(v4);
20469 sequence.push_back(v5); sequence.push_back(v6);
20470 sequence.push_back(v7); sequence.push_back(v8);
20471 sequence.push_back(v9); sequence.push_back(v10);
20472 sequence.push_back(v11);
20475 template <
typename T,
20476 typename Allocator,
20477 template <
typename,
typename>
class Sequence>
20479 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20480 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20481 const T& v9,
const T& v10)
20483 sequence.push_back(v1); sequence.push_back(v2);
20484 sequence.push_back(v3); sequence.push_back(v4);
20485 sequence.push_back(v5); sequence.push_back(v6);
20486 sequence.push_back(v7); sequence.push_back(v8);
20487 sequence.push_back(v9); sequence.push_back(v10);
20490 template <
typename T,
20491 typename Allocator,
20492 template <
typename,
typename>
class Sequence>
20494 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20495 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20498 sequence.push_back(v1); sequence.push_back(v2);
20499 sequence.push_back(v3); sequence.push_back(v4);
20500 sequence.push_back(v5); sequence.push_back(v6);
20501 sequence.push_back(v7); sequence.push_back(v8);
20502 sequence.push_back(v9);
20505 template <
typename T,
20506 typename Allocator,
20507 template <
typename,
typename>
class Sequence>
20509 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20510 const T& v5,
const T& v6,
const T& v7,
const T& v8)
20512 sequence.push_back(v1); sequence.push_back(v2);
20513 sequence.push_back(v3); sequence.push_back(v4);
20514 sequence.push_back(v5); sequence.push_back(v6);
20515 sequence.push_back(v7); sequence.push_back(v8);
20518 template <
typename T,
20519 typename Allocator,
20520 template <
typename,
typename>
class Sequence>
20522 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20523 const T& v5,
const T& v6,
const T& v7)
20525 sequence.push_back(v1); sequence.push_back(v2);
20526 sequence.push_back(v3); sequence.push_back(v4);
20527 sequence.push_back(v5); sequence.push_back(v6);
20528 sequence.push_back(v7);
20531 template <
typename T,
20532 typename Allocator,
20533 template <
typename,
typename>
class Sequence>
20535 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20536 const T& v5,
const T& v6)
20538 sequence.push_back(v1); sequence.push_back(v2);
20539 sequence.push_back(v3); sequence.push_back(v4);
20540 sequence.push_back(v5); sequence.push_back(v6);
20543 template <
typename T,
20544 typename Allocator,
20545 template <
typename,
typename>
class Sequence>
20547 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20550 sequence.push_back(v1); sequence.push_back(v2);
20551 sequence.push_back(v3); sequence.push_back(v4);
20552 sequence.push_back(v5);
20555 template <
typename T,
20556 typename Allocator,
20557 template <
typename,
typename>
class Sequence>
20559 const T& v1,
const T& v2,
const T& v3,
const T& v4)
20561 sequence.push_back(v1); sequence.push_back(v2);
20562 sequence.push_back(v3); sequence.push_back(v4);
20565 template <
typename T,
20566 typename Allocator,
20567 template <
typename,
typename>
class Sequence>
20569 const T& v1,
const T& v2,
const T& v3)
20571 sequence.push_back(v1); sequence.push_back(v2);
20572 sequence.push_back(v3);
20575 template <
typename T,
20576 typename Allocator,
20577 template <
typename,
typename>
class Sequence>
20579 const T& v1,
const T& v2)
20581 sequence.push_back(v1); sequence.push_back(v2);
20584 template <
typename T,
20585 typename Allocator,
20586 template <
typename,
typename>
class Sequence>
20590 sequence.push_back(v1);
20593 template <
typename T,
typename Comparator,
typename Allocator>
20595 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20596 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20597 const T& v9,
const T& v10)
20599 set.insert(v1); set.insert(v2);
20600 set.insert(v3); set.insert(v4);
20601 set.insert(v5); set.insert(v6);
20602 set.insert(v7); set.insert(v8);
20603 set.insert(v9); set.insert(v10);
20606 template <
typename T,
typename Comparator,
typename Allocator>
20608 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20609 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20612 set.insert(v1); set.insert(v2);
20613 set.insert(v3); set.insert(v4);
20614 set.insert(v5); set.insert(v6);
20615 set.insert(v7); set.insert(v8);
20619 template <
typename T,
typename Comparator,
typename Allocator>
20621 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20622 const T& v5,
const T& v6,
const T& v7,
const T& v8)
20624 set.insert(v1); set.insert(v2);
20625 set.insert(v3); set.insert(v4);
20626 set.insert(v5); set.insert(v6);
20627 set.insert(v7); set.insert(v8);
20630 template <
typename T,
typename Comparator,
typename Allocator>
20632 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20633 const T& v5,
const T& v6,
const T& v7)
20635 set.insert(v1); set.insert(v2);
20636 set.insert(v3); set.insert(v4);
20637 set.insert(v5); set.insert(v6);
20641 template <
typename T,
typename Comparator,
typename Allocator>
20643 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20644 const T& v5,
const T& v6)
20646 set.insert(v1); set.insert(v2);
20647 set.insert(v3); set.insert(v4);
20648 set.insert(v5); set.insert(v6);
20651 template <
typename T,
typename Comparator,
typename Allocator>
20653 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20656 set.insert(v1); set.insert(v2);
20657 set.insert(v3); set.insert(v4);
20661 template <
typename T,
typename Comparator,
typename Allocator>
20663 const T& v1,
const T& v2,
const T& v3,
const T& v4)
20665 set.insert(v1); set.insert(v2);
20666 set.insert(v3); set.insert(v4);
20669 template <
typename T,
typename Comparator,
typename Allocator>
20671 const T& v1,
const T& v2,
const T& v3)
20673 set.insert(v1); set.insert(v2);
20677 template <
typename T,
typename Comparator,
typename Allocator>
20679 const T& v1,
const T& v2)
20681 set.insert(v1); set.insert(v2);
20684 template <
typename T,
typename Comparator,
typename Allocator>
20691 template <
typename T,
typename Comparator,
typename Allocator>
20692 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20693 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20694 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20695 const T& v9,
const T& v10)
20697 set.insert(v1); set.insert(v2);
20698 set.insert(v3); set.insert(v4);
20699 set.insert(v5); set.insert(v6);
20700 set.insert(v7); set.insert(v8);
20701 set.insert(v9); set.insert(v10);
20704 template <
typename T,
typename Comparator,
typename Allocator>
20705 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20706 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20707 const T& v5,
const T& v6,
const T& v7,
const T& v8,
20710 set.insert(v1); set.insert(v2);
20711 set.insert(v3); set.insert(v4);
20712 set.insert(v5); set.insert(v6);
20713 set.insert(v7); set.insert(v8);
20717 template <
typename T,
typename Comparator,
typename Allocator>
20718 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20719 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20720 const T& v5,
const T& v6,
const T& v7,
const T& v8)
20722 set.insert(v1); set.insert(v2);
20723 set.insert(v3); set.insert(v4);
20724 set.insert(v5); set.insert(v6);
20725 set.insert(v7); set.insert(v8);
20728 template <
typename T,
typename Comparator,
typename Allocator>
20729 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20730 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20731 const T& v5,
const T& v6,
const T& v7)
20733 set.insert(v1); set.insert(v2);
20734 set.insert(v3); set.insert(v4);
20735 set.insert(v5); set.insert(v6);
20739 template <
typename T,
typename Comparator,
typename Allocator>
20740 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20741 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20742 const T& v5,
const T& v6)
20744 set.insert(v1); set.insert(v2);
20745 set.insert(v3); set.insert(v4);
20746 set.insert(v5); set.insert(v6);
20749 template <
typename T,
typename Comparator,
typename Allocator>
20750 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20751 const T& v1,
const T& v2,
const T& v3,
const T& v4,
20754 set.insert(v1); set.insert(v2);
20755 set.insert(v3); set.insert(v4);
20759 template <
typename T,
typename Comparator,
typename Allocator>
20760 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20761 const T& v1,
const T& v2,
const T& v3,
const T& v4)
20763 set.insert(v1); set.insert(v2);
20764 set.insert(v3); set.insert(v4);
20767 template <
typename T,
typename Comparator,
typename Allocator>
20768 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20769 const T& v1,
const T& v2,
const T& v3)
20771 set.insert(v1); set.insert(v2);
20775 template <
typename T,
typename Comparator,
typename Allocator>
20776 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20777 const T& v1,
const T& v2)
20779 set.insert(v1); set.insert(v2);
20782 template <
typename T,
typename Comparator,
typename Allocator>
20783 inline void push_back(std::multiset<T,Comparator,Allocator>& set,
20789 template <
typename T,
20790 typename Allocator,
20791 template <
typename,
typename>
class Sequence>
20792 inline void clear(Sequence<T,Allocator>& sequence)
20797 template <
typename T,
20798 typename Comparator,
20799 typename Allocator>
20800 inline void clear(std::set<T,Comparator,Allocator>& set)
20802 std::set<T> null_set;
20806 template <
typename T,
20807 typename Comparator,
20808 typename Allocator>
20809 inline void clear(std::multiset<T,Comparator,Allocator>& multiset)
20811 std::multiset<T> null_set;
20815 template <
typename T,
typename Container>
20816 inline void clear(std::queue<T,Container>& queue)
20818 std::queue<T> null_que;
20822 template <
typename T,
typename Container>
20823 inline void clear(std::stack<T,Container>& stack)
20825 std::stack<T> null_stack;
20829 template <
typename T,
20830 typename Container,
20831 typename Comparator>
20832 inline void clear(std::priority_queue<T,Container,Comparator>& priority_queue)
20834 std::priority_queue<T> null_pqueue;
20842 template <std::
size_t N>
20846 std::size_t index_list[N];
20849 template <
typename Cli, std::
size_t N>
20858 : column_list_(column_list),
20860 target_index_(column_list_.index_list[0]),
20861 col_list_index_(0),
20880 template <
typename Iterator>
20889 current_index_ = 0;
20890 col_list_index_ = 0;
20891 target_index_ = column_list_.index_list[0];
20907 std::fill_n(value_list,N,null_value);
20910 template <
typename T>
20913 if (current_index < N)
20915 value_list[current_index].first.assign(t);
20916 value_list[current_index].second =
false;
20925 template <
typename Iterator>
20926 inline void process(
const std::pair<Iterator,Iterator>& r)
20928 if (current_index_ > target_index_)
20930 else if (current_index_ == target_index_)
20932 typename colsel_value_list::value_t& v = cvl_.value_list[col_list_index_];
20933 if (
true != (v.second = v.first(r.first,r.second)))
20938 if (col_list_index_ < column_list_t::size)
20939 target_index_ = column_list_.index_list[col_list_index_];
20941 target_index_ = std::numeric_limits<std::size_t>::max();
20963 template <
typename T0 = void,
typename T1 = void,
typename T2 = void,
typename T3 = void,
typename T4 = void,
20964 typename T5 = void,
typename T6 = void,
typename T7 = void,
typename T8 = void,
typename T9 = void,
20965 typename T10 = void,
typename T11 =
void>
20967 :
public column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>,12>
20971 typedef column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>,12>
csb_t;
20975 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
20976 T5& t5, T6& t6, T7& t7, T8& t8, T9& t9,
20977 T10& t10, T11& t11)
20978 :
csb_t(column_list)
20980 csb_t::cvl().register_value( t0); csb_t::cvl().register_value( t1);
20981 csb_t::cvl().register_value( t2); csb_t::cvl().register_value( t3);
20982 csb_t::cvl().register_value( t4); csb_t::cvl().register_value( t5);
20983 csb_t::cvl().register_value( t6); csb_t::cvl().register_value( t7);
20984 csb_t::cvl().register_value( t8); csb_t::cvl().register_value( t9);
20985 csb_t::cvl().register_value(t10); csb_t::cvl().register_value(t11);
20989 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
20990 typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
20992 class column_selector_impl <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>
20993 :
public column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>,11>
20997 typedef column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>,11>
csb_t;
21001 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
21002 T5& t5, T6& t6, T7& t7, T8& t8, T9& t9,
21004 :
csb_t(column_list)
21006 csb_t::cvl().register_value( t0); csb_t::cvl().register_value( t1);
21007 csb_t::cvl().register_value( t2); csb_t::cvl().register_value( t3);
21008 csb_t::cvl().register_value( t4); csb_t::cvl().register_value( t5);
21009 csb_t::cvl().register_value( t6); csb_t::cvl().register_value( t7);
21010 csb_t::cvl().register_value( t8); csb_t::cvl().register_value( t9);
21011 csb_t::cvl().register_value(t10);
21015 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21016 typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
21018 :
public column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>,10>
21022 typedef column_selector_base<column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>,10>
csb_t;
21026 T1& t0, T1& t1, T2& t2, T3& t3, T4& t4,
21027 T5& t5, T6& t6, T7& t7, T8& t8, T9& t9)
21028 :
csb_t(column_list)
21030 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21031 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21032 csb_t::cvl().register_value(t4); csb_t::cvl().register_value(t5);
21033 csb_t::cvl().register_value(t6); csb_t::cvl().register_value(t7);
21034 csb_t::cvl().register_value(t8); csb_t::cvl().register_value(t9);
21038 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21039 typename T5,
typename T6,
typename T7,
typename T8>
21049 T1& t0, T1& t1, T2& t2, T3& t3, T4& t4,
21050 T5& t5, T6& t6, T7& t7, T8& t8)
21051 :
csb_t(column_list)
21053 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21054 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21055 csb_t::cvl().register_value(t4); csb_t::cvl().register_value(t5);
21056 csb_t::cvl().register_value(t6); csb_t::cvl().register_value(t7);
21057 csb_t::cvl().register_value(t8);
21061 template <
typename T0,
typename T1,
typename T2,
typename T3,
21062 typename T4,
typename T5,
typename T6,
typename T7>
21072 T1& t0, T1& t1, T2& t2, T3& t3,
21073 T4& t4, T5& t5, T6& t6, T7& t7)
21074 :
csb_t(column_list)
21076 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21077 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21078 csb_t::cvl().register_value(t4); csb_t::cvl().register_value(t5);
21079 csb_t::cvl().register_value(t6); csb_t::cvl().register_value(t7);
21083 template <
typename T0,
typename T1,
typename T2,
typename T3,
21084 typename T4,
typename T5,
typename T6>
21094 T1& t0, T1& t1, T2& t2, T3& t3,
21095 T4& t4, T5& t5, T6& t6)
21096 :
csb_t(column_list)
21098 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21099 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21100 csb_t::cvl().register_value(t4); csb_t::cvl().register_value(t5);
21101 csb_t::cvl().register_value(t6);
21105 template <
typename T0,
typename T1,
typename T2,
21106 typename T3,
typename T4,
typename T5>
21116 T1& t0, T1& t1, T2& t2,
21117 T3& t3, T4& t4, T5& t5)
21118 :
csb_t(column_list)
21120 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21121 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21122 csb_t::cvl().register_value(t4); csb_t::cvl().register_value(t5);
21126 template <
typename T0,
typename T1,
typename T2,
21127 typename T3,
typename T4>
21137 T1& t0, T1& t1, T2& t2,
21139 :
csb_t(column_list)
21141 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21142 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21143 csb_t::cvl().register_value(t4);
21147 template <
typename T0,
typename T1,
typename T2,
typename T3>
21157 T1& t0, T1& t1, T2& t2, T3& t3)
21158 :
csb_t(column_list)
21160 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21161 csb_t::cvl().register_value(t2); csb_t::cvl().register_value(t3);
21165 template <
typename T0,
typename T1,
typename T2>
21175 T1& t0, T1& t1, T2& t2)
21176 :
csb_t(column_list)
21178 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21179 csb_t::cvl().register_value(t2);
21183 template <
typename T0,
typename T1>
21194 :
csb_t(column_list)
21196 csb_t::cvl().register_value(t0); csb_t::cvl().register_value(t1);
21200 template <
typename T0>
21210 :
csb_t(column_list)
21212 csb_t::cvl().register_value(t0);
21218 inline details::column_list_impl<12>
21220 const std::size_t& idx2,
const std::size_t& idx3,
21221 const std::size_t& idx4,
const std::size_t& idx5,
21222 const std::size_t& idx6,
const std::size_t& idx7,
21223 const std::size_t& idx8,
const std::size_t& idx9,
21224 const std::size_t& idx10,
const std::size_t& idx11)
21236 inline details::column_list_impl<11>
21238 const std::size_t& idx2,
const std::size_t& idx3,
21239 const std::size_t& idx4,
const std::size_t& idx5,
21240 const std::size_t& idx6,
const std::size_t& idx7,
21241 const std::size_t& idx8,
const std::size_t& idx9,
21242 const std::size_t& idx10)
21254 inline details::column_list_impl<10>
21256 const std::size_t& idx2,
const std::size_t& idx3,
21257 const std::size_t& idx4,
const std::size_t& idx5,
21258 const std::size_t& idx6,
const std::size_t& idx7,
21259 const std::size_t& idx8,
const std::size_t& idx9)
21270 inline details::column_list_impl<9>
21272 const std::size_t& idx2,
const std::size_t& idx3,
21273 const std::size_t& idx4,
const std::size_t& idx5,
21274 const std::size_t& idx6,
const std::size_t& idx7,
21275 const std::size_t& idx8)
21286 inline details::column_list_impl<8>
21288 const std::size_t& idx2,
const std::size_t& idx3,
21289 const std::size_t& idx4,
const std::size_t& idx5,
21290 const std::size_t& idx6,
const std::size_t& idx7)
21300 inline details::column_list_impl<7>
21302 const std::size_t& idx2,
const std::size_t& idx3,
21303 const std::size_t& idx4,
const std::size_t& idx5,
21304 const std::size_t& idx6)
21314 inline details::column_list_impl<6>
21316 const std::size_t& idx2,
const std::size_t& idx3,
21317 const std::size_t& idx4,
const std::size_t& idx5)
21326 inline details::column_list_impl<5>
21328 const std::size_t& idx2,
const std::size_t& idx3,
21329 const std::size_t& idx4)
21338 inline details::column_list_impl<4>
21340 const std::size_t& idx2,
const std::size_t& idx3)
21348 inline details::column_list_impl<3>
21350 const std::size_t& idx2)
21358 inline details::column_list_impl<2>
21366 inline details::column_list_impl<1>
21376 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],
21377 idx[6],idx[7],idx[8],idx[9],idx[10],idx[11]);
21382 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],
21383 idx[6],idx[7],idx[8],idx[9],idx[10]);
21388 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],
21389 idx[6],idx[7],idx[8],idx[9]);
21394 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],
21395 idx[6],idx[7],idx[8]);
21400 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],
21406 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5],idx[6]);
21411 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4],idx[5]);
21416 return column_list(idx[0],idx[1],idx[2],idx[3],idx[4]);
21439 template <
typename T0,
typename T1,
typename T2,
typename T3,
21440 typename T4,
typename T5,
typename T6,
typename T7,
21441 typename T8,
typename T9,
typename T10,
typename T11>
21442 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
21444 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21445 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10, T11& t11)
21449 <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>
21450 (col_list,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11);
21453 template <
typename T0,
typename T1,
typename T2,
typename T3,
21454 typename T4,
typename T5,
typename T6,
typename T7,
21455 typename T8,
typename T9,
typename T10>
21456 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
21458 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21459 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10)
21463 <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>
21464 (col_list,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10);
21467 template <
typename T0,
typename T1,
typename T2,
typename T3,
21468 typename T4,
typename T5,
typename T6,
typename T7,
21469 typename T8,
typename T9>
21470 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
21472 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21473 T6& t6, T7& t7, T8& t8, T9& t9)
21477 <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>
21478 (col_list,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9);
21481 template <
typename T0,
typename T1,
typename T2,
typename T3,
21482 typename T4,
typename T5,
typename T6,
typename T7,
21484 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7,T8>
21486 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21487 T6& t6, T7& t7, T8& t8)
21491 <T0,T1,T2,T3,T4,T5,T6,T7,T8>
21492 (col_list,t0,t1,t2,t3,t4,t5,t6,t7,t8);
21495 template <
typename T0,
typename T1,
typename T2,
typename T3,
21496 typename T4,
typename T5,
typename T6,
typename T7>
21497 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6,T7>
21499 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21504 <T0,T1,T2,T3,T4,T5,T6,T7>
21505 (col_list,t0,t1,t2,t3,t4,t5,t6,t7);
21508 template <
typename T0,
typename T1,
typename T2,
typename T3,
21509 typename T4,
typename T5,
typename T6>
21510 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5,T6>
21512 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6)
21516 <T0,T1,T2,T3,T4,T5,T6>
21517 (col_list,t0,t1,t2,t3,t4,t5,t6);
21520 template <
typename T0,
typename T1,
typename T2,
typename T3,
21521 typename T4,
typename T5>
21522 inline typename details::column_selector_impl<T0,T1,T2,T3,T4,T5>
21524 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
21528 <T0,T1,T2,T3,T4,T5>
21529 (col_list,t0,t1,t2,t3,t4,t5);
21532 template <
typename T0,
typename T1,
typename T2,
21533 typename T3,
typename T4>
21534 inline typename details::column_selector_impl<T0,T1,T2,T3,T4>
21536 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4)
21541 (col_list,t0,t1,t2,t3,t4);
21544 template <
typename T0,
typename T1,
typename T2,
typename T3>
21545 inline typename details::column_selector_impl<T0,T1,T2,T3>
21547 T0& t0, T1& t1, T2& t2, T3& t3)
21552 (col_list,t0,t1,t2,t3);
21555 template <
typename T0,
typename T1,
typename T2>
21556 inline typename details::column_selector_impl<T0,T1,T2>
21558 T0& t0, T1& t1, T2& t2)
21563 (col_list,t0,t1,t2);
21566 template <
typename T0,
typename T1>
21567 inline typename details::column_selector_impl<T0,T1>
21577 template <
typename T0>
21578 inline typename details::column_selector_impl<T0>
21589 template <
typename Iterator>
21590 inline Iterator
inc(Iterator itr,
const std::size_t& n)
21592 std::advance(itr,n);
21597 template <
typename T, std::
size_t N>
21601 template <
typename T>
21607 template <
typename Allocator,
21608 template <
typename,
typename>
class Sequence>
21611 return type(col_list,seq[0]);
21614 template <
typename Allocator>
21617 typename std::list<T,Allocator>::iterator b = list.begin();
21618 return type(col_list,*(b));
21622 template <
typename T>
21628 template <
typename Allocator,
21629 template <
typename,
typename>
class Sequence>
21632 return type(col_list,seq[0],seq[1]);
21635 template <
typename Allocator>
21638 typename std::list<T,Allocator>::iterator b = list.begin();
21639 return type(col_list,*(b),*
inc(b,1));
21643 template <
typename T>
21649 template <
typename Allocator,
21650 template <
typename,
typename>
class Sequence>
21653 return type(col_list,seq[0],seq[1],seq[2]);
21656 template <
typename Allocator>
21659 typename std::list<T,Allocator>::iterator b = list.begin();
21660 return type(col_list,*(b),*
inc(b,1),*
inc(b,2));
21664 template <
typename T>
21670 template <
typename Allocator,
21671 template <
typename,
typename>
class Sequence>
21674 return type(col_list,seq[0],seq[1],seq[2],seq[3]);
21677 template <
typename Allocator>
21680 typename std::list<T,Allocator>::iterator b = list.begin();
21685 template <
typename T>
21691 template <
typename Allocator,
21692 template <
typename,
typename>
class Sequence>
21695 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4]);
21698 template <
typename Allocator>
21701 typename std::list<T,Allocator>::iterator b = list.begin();
21706 template <
typename T>
21712 template <
typename Allocator,
21713 template <
typename,
typename>
class Sequence>
21716 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4],seq[5]);
21719 template <
typename Allocator>
21722 typename std::list<T,Allocator>::iterator b = list.begin();
21723 return type(col_list,*(b),*
inc(b,1),*
inc(b,2),*
inc(b,3),*
inc(b,4),*
inc(b,5));
21727 template <
typename T>
21733 template <
typename Allocator,
21734 template <
typename,
typename>
class Sequence>
21737 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4],seq[5],seq[6]);
21740 template <
typename Allocator>
21743 typename std::list<T,Allocator>::iterator b = list.begin();
21744 return type(col_list,*(b),*
inc(b,1),*
inc(b,2),*
inc(b,3),*
inc(b,4),*
inc(b,5),*
inc(b,6));
21748 template <
typename T>
21754 template <
typename Allocator,
21755 template <
typename,
typename>
class Sequence>
21758 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4],seq[5],seq[6],seq[7]);
21761 template <
typename Allocator>
21764 typename std::list<T,Allocator>::iterator b = list.begin();
21765 return type(col_list,*(b),*
inc(b,1),*
inc(b,2),*
inc(b,3),*
inc(b,4),*
inc(b,5),*
inc(b,6),*
inc(b,7));
21769 template <
typename T>
21775 template <
typename Allocator,
21776 template <
typename,
typename>
class Sequence>
21779 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4],seq[5],seq[6],seq[7],seq[8]);
21782 template <
typename Allocator>
21785 typename std::list<T,Allocator>::iterator b = list.begin();
21786 return type(col_list,*(b),*
inc(b,1),*
inc(b,2),*
inc(b,3),*
inc(b,4),*
inc(b,5),*
inc(b,6),*
inc(b,7),*
inc(b,8));
21790 template <
typename T>
21796 template <
typename Allocator,
21797 template <
typename,
typename>
class Sequence>
21800 return type(col_list,seq[0],seq[1],seq[2],seq[3],seq[4],seq[5],seq[6],seq[7],seq[8],seq[9]);
21803 template <
typename Allocator>
21806 typename std::list<T,Allocator>::iterator b = list.begin();
21807 return type(col_list,*(b),*
inc(b,1),*
inc(b,2),*
inc(b,3),*
inc(b,4),*
inc(b,5),*
inc(b,6),*
inc(b,7),*
inc(b,8),*
inc(b,9));
21813 template <std::size_t N,
21815 typename Allocator,
21816 template <
typename,
typename>
class Sequence>
21820 if (seq.size() >= N)
21823 return composer_t::create(col_list,seq);
21826 throw std::invalid_argument(
"column_selector(sequence/list) - size < N!");
21832 template <
typename InputIterator, std::
size_t N>
21843 : column_list_(column_list),
21844 token_list_(token_list),
21846 target_index_(column_list_.index_list[0]),
21865 template <
typename Iterator>
21868 if (current_index_ == target_index_)
21870 token_list_[col_list_index_] = r;
21872 if (col_list_index_ < column_list_t::size)
21873 target_index_ = column_list_.index_list[col_list_index_];
21875 target_index_ = std::numeric_limits<std::size_t>::max();
21883 csii_t& operator=(
const csii_t& csb);
21885 const column_list_t& column_list_;
21886 iterator_type_ptr token_list_;
21887 std::size_t current_index_;
21888 std::size_t target_index_;
21889 std::size_t col_list_index_;
21894 #define strtk_parse_col_token(Index)\
21895 if (!string_to_type_converter(token_list[Index].first,token_list[Index].second,t##Index)) return false;
21897 #define strtk_parse_col_token_seq(Index)\
21898 if (!string_to_type_converter(token_list[Index].first,token_list[Index].second,seq[Index])) return false;
21900 #define strtk_parse_columns_impl(NN)\
21901 static const std::size_t N = NN;\
21902 typedef typename details::is_valid_iterator<InputIterator>::type itr_type;\
21903 typedef std::pair<InputIterator,InputIterator> iterator_type;\
21904 typedef details::column_selector_iterator_impl<InputIterator,N> csii_t;\
21905 const std::size_t token_count = (column_list.index_list[N - 1] + 1);\
21906 iterator_type token_list[N];\
21907 csii_t csii(column_list,token_list);\
21908 const std::size_t parsed_token_count = split_n<InputIterator,csii_t&>\
21909 (delimiters,begin,end,token_count,csii,split_options::compress_delimiters);\
21910 if (token_count > parsed_token_count) return false;\
21912 #define strk_parse_col_seq\
21913 return parse_columns(data.data(),data.data() + data.size(),delimiters,column_list,seq);
21915 template <
typename InputIterator,
21916 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21917 typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
21918 typename T10,
typename T11>
21920 const InputIterator end,
21923 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21924 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10, T11& t11)
21936 template <
typename InputIterator,
21937 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21938 typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
21941 const InputIterator end,
21944 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21945 T6& t6, T7& t7, T8& t8, T9& t9, T10& t10)
21957 template <
typename InputIterator,
21958 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21959 typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
21961 const InputIterator end,
21964 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5,
21965 T6& t6, T7& t7, T8& t8, T9& t9)
21976 template <
typename InputIterator,
21977 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21978 typename T5,
typename T6,
typename T7,
typename T8>
21980 const InputIterator end,
21983 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6,
21995 template <
typename InputIterator,
21996 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
21997 typename T5,
typename T6,
typename T7>
21999 const InputIterator end,
22002 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6, T7& t7)
22012 template <
typename InputIterator,
22013 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22014 typename T5,
typename T6>
22016 const InputIterator end,
22019 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5, T6& t6)
22029 template <
typename InputIterator,
22030 typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22033 const InputIterator end,
22036 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4, T5& t5)
22045 template <
typename InputIterator,
22046 typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
22048 const InputIterator end,
22051 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4)
22060 template <
typename InputIterator,
22061 typename T0,
typename T1,
typename T2,
typename T3>
22063 const InputIterator end,
22066 T0& t0, T1& t1, T2& t2, T3& t3)
22074 template <
typename InputIterator,
22075 typename T0,
typename T1,
typename T2>
22077 const InputIterator end,
22080 T0& t0, T1& t1, T2& t2)
22088 template <
typename InputIterator,
22089 typename T0,
typename T1>
22091 const InputIterator end,
22101 template <
typename InputIterator,
22104 const InputIterator end,
22114 template <
typename InputIterator,
22116 typename Allocator,
22117 template <
typename,
typename>
class Sequence>
22119 const InputIterator end,
22122 Sequence<T,Allocator>& seq)
22134 template <
typename InputIterator,
22136 typename Allocator,
22137 template <
typename,
typename>
class Sequence>
22139 const InputIterator end,
22142 Sequence<T,Allocator>& seq)
22154 template <
typename InputIterator,
22156 typename Allocator,
22157 template <
typename,
typename>
class Sequence>
22159 const InputIterator end,
22162 Sequence<T,Allocator>& seq)
22173 template <
typename InputIterator,
22175 typename Allocator,
22176 template <
typename,
typename>
class Sequence>
22178 const InputIterator end,
22181 Sequence<T,Allocator>& seq)
22192 template <
typename InputIterator,
22194 typename Allocator,
22195 template <
typename,
typename>
class Sequence>
22197 const InputIterator end,
22200 Sequence<T,Allocator>& seq)
22210 template <
typename InputIterator,
22212 typename Allocator,
22213 template <
typename,
typename>
class Sequence>
22215 const InputIterator end,
22218 Sequence<T,Allocator>& seq)
22228 template <
typename InputIterator,
22230 typename Allocator,
22231 template <
typename,
typename>
class Sequence>
22233 const InputIterator end,
22236 Sequence<T,Allocator>& seq)
22245 template <
typename InputIterator,
22247 typename Allocator,
22248 template <
typename,
typename>
class Sequence>
22250 const InputIterator end,
22253 Sequence<T,Allocator>& seq)
22262 template <
typename InputIterator,
22264 typename Allocator,
22265 template <
typename,
typename>
class Sequence>
22267 const InputIterator end,
22270 Sequence<T,Allocator>& seq)
22278 template <
typename InputIterator,
22280 typename Allocator,
22281 template <
typename,
typename>
class Sequence>
22283 const InputIterator end,
22286 Sequence<T,Allocator>& seq)
22294 template <
typename InputIterator,
22296 typename Allocator,
22297 template <
typename,
typename>
class Sequence>
22299 const InputIterator end,
22302 Sequence<T,Allocator>& seq)
22309 template <
typename InputIterator,
22311 typename Allocator,
22312 template <
typename,
typename>
class Sequence>
22314 const InputIterator end,
22317 Sequence<T,Allocator>& seq)
22324 #undef strtk_parse_col_token
22325 #undef strtk_parse_col_token_seq
22326 #undef strtk_parse_columns_impl
22328 #define strtk_parse_col_begin()\
22329 return parse_columns(data.data(),\
22330 data.data() + data.size(),delimiters,\
22333 #define strtk_parse_col_end() );
22335 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22336 typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
22337 typename T10,
typename T11>
22341 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22342 T5& t5, T6& t6, T7& t7, T8& t8, T9& t9,
22343 T10& t10, T11& t11)
22346 t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11
22350 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22351 typename T5,
typename T6,
typename T7,
typename T8,
typename T9,
22356 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22357 T5& t5, T6& t6, T7& t7, T8& t8, T9& t9,
22361 t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10
22365 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22366 typename T5,
typename T6,
typename T7,
typename T8,
typename T9>
22370 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22371 T5& t5, T6& t6, T7& t7, T8& t8,
22375 t0,t1,t2,t3,t4,t5,t6,t7,t8,t9
22379 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22380 typename T5,
typename T6,
typename T7,
typename T8>
22384 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22385 T5& t5, T6& t6, T7& t7, T8& t8)
22388 t0,t1,t2,t3,t4,t5,t6,t7,t8
22392 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22393 typename T5,
typename T6,
typename T7>
22397 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22398 T5& t5, T6& t6, T7& t7)
22401 t0,t1,t2,t3,t4,t5,t6,t7
22405 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22406 typename T5,
typename T6>
22410 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22414 t0,t1,t2,t3,t4,t5,t6
22418 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
22423 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4,
22431 template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4>
22435 T0& t0, T1& t1, T2& t2, T3& t3, T4& t4)
22442 template <
typename T0,
typename T1,
typename T2,
typename T3>
22446 T0& t0, T1& t1, T2& t2, T3& t3)
22453 template <
typename T0,
typename T1,
typename T2>
22457 T0& t0, T1& t1, T2& t2)
22464 template <
typename T0,
typename T1>
22475 template <
typename T>
22486 #undef strtk_parse_col_begin
22487 #undef strtk_parse_col_end
22489 template <
typename T,
22490 typename Allocator,
22491 template <
typename,
typename>
class Sequence>
22495 Sequence<T,Allocator>& seq)
22500 template <
typename T,
22501 typename Allocator,
22502 template <
typename,
typename>
class Sequence>
22506 Sequence<T,Allocator>& seq)
22511 template <
typename T,
22512 typename Allocator,
22513 template <
typename,
typename>
class Sequence>
22517 Sequence<T,Allocator>& seq)
22522 template <
typename T,
22523 typename Allocator,
22524 template <
typename,
typename>
class Sequence>
22528 Sequence<T,Allocator>& seq)
22533 template <
typename T,
22534 typename Allocator,
22535 template <
typename,
typename>
class Sequence>
22539 Sequence<T,Allocator>& seq)
22544 template <
typename T,
22545 typename Allocator,
22546 template <
typename,
typename>
class Sequence>
22550 Sequence<T,Allocator>& seq)
22555 template <
typename T,
22556 typename Allocator,
22557 template <
typename,
typename>
class Sequence>
22561 Sequence<T,Allocator>& seq)
22566 template <
typename T,
22567 typename Allocator,
22568 template <
typename,
typename>
class Sequence>
22572 Sequence<T,Allocator>& seq)
22577 template <
typename T,
22578 typename Allocator,
22579 template <
typename,
typename>
class Sequence>
22583 Sequence<T,Allocator>& seq)
22588 template <
typename T,
22589 typename Allocator,
22590 template <
typename,
typename>
class Sequence>
22594 Sequence<T,Allocator>& seq)
22599 template <
typename T,
22600 typename Allocator,
22601 template <
typename,
typename>
class Sequence>
22605 Sequence<T,Allocator>& seq)
22610 template <
typename T,
22611 typename Allocator,
22612 template <
typename,
typename>
class Sequence>
22616 Sequence<T,Allocator>& seq)
22621 #undef strk_parse_col_seq
22627 template <
typename T>
22628 bool cmpimpl(
ptr c1,
ptr c2) {
return (*reinterpret_cast<T>(c1)) == (*
reinterpret_cast<T>(c2)); }
22630 template <std::
size_t K>
22634 struct size_impl<8> {
static inline bool cmp(
ptr c1,
ptr c2) {
return cmpimpl<const unsigned long long*>(c1,c2); } };
22637 struct size_impl<4> {
static inline bool cmp(
ptr c1,
ptr c2) {
return cmpimpl<const unsigned int*>(c1,c2); } };
22640 struct size_impl<2> {
static inline bool cmp(
ptr c1,
ptr c2) {
return cmpimpl<const unsigned short*>(c1,c2); } };
22643 struct size_impl<1> {
static inline bool cmp(
ptr c1,
ptr c2) {
return cmpimpl<const unsigned char*>(c1,c2); } };
22645 template <std::
size_t N>
22646 struct next_size {
enum { size = (N >= 8) ? 8 : ((N >= 4) ? 4 : ((N >= 2) ? 2 : 1)) }; };
22648 template <std::
size_t N>
22657 static inline bool process(
const char* c1,
const char* c2)
22662 template <std::
size_t K1, std::
size_t K2>
22663 static inline bool process(
const unsigned char (&c1)[K1],
const unsigned char (&c2)[K2])
22672 template <std::
size_t N>
22678 template <std::
size_t N>
22684 template <std::
size_t N,std::
size_t K1, std::
size_t K2>
22685 inline bool memcmp_n(
const unsigned char (&c1)[K1],
const unsigned char (&c2)[K2])
22698 template <
typename Iterator>
22699 inline std::size_t
distance(
const std::pair<Iterator,Iterator>& p)
22704 template <
typename Iterator1,
typename Iterator2>
22707 return std::make_pair<Iterator1,Iterator2>(
22708 reinterpret_cast<Iterator1
>(
const_cast<char*
>(s.data())),
22709 reinterpret_cast<Iterator2
>(
const_cast<char*
>(s.data() + s.size())));
22712 template <
typename Iterator1,
typename Iterator2>
22713 inline std::pair<Iterator1,Iterator2>
make_pair(
const std::pair<const char*, const char*> p)
22715 return std::make_pair<Iterator1,Iterator2>(
22716 reinterpret_cast<Iterator1
>(
const_cast<char*
>(p.first)),
22717 reinterpret_cast<Iterator2
>(
const_cast<char*
>(p.second)));
22720 template <
typename Iterator>
22723 return make_pair<Iterator,Iterator>(s);
22726 template <
typename Iterator>
22727 inline std::pair<Iterator,Iterator>
make_pair(
const std::pair<const char*, const char*>& p)
22729 return make_pair<Iterator,Iterator>(p);
22732 template <
typename Iterator1,
typename Iterator2>
22735 return std::make_pair<Iterator1,Iterator2>(
22736 reinterpret_cast<Iterator1
>(
const_cast<char*
>(range.
begin())),
22737 reinterpret_cast<Iterator2
>(
const_cast<char*
>(range.
end())));
22740 template <std::
size_t N>
22745 return null_string;
22750 template <std::
size_t N>
22755 return null_string;
22765 template <
typename T, std::
size_t N>
22771 std::fill_n(&a[0],length,t);
22775 template <std::
size_t N>
22778 const bool pad =
false,
22779 const unsigned char padding =
'0')
22783 std::copy(s.data(),s.data() + s.size(), &a[0]);
22784 if ((s.size() < N) && pad)
22785 std::fill_n(&a[s.size()],N - s.size(),padding);
22789 template <std::
size_t N, std::
size_t M>
22791 unsigned char (&src)[M],
22792 const bool pad =
false,
22793 const unsigned char padding =
'0')
22797 std::copy(src,src + N, &dest[0]);
22798 if ((M < N) && pad)
22799 std::fill_n(&dest[M],N - M,padding);
22805 char* begin =
const_cast<char*
>(range.first);
22806 char* end =
const_cast<char*
>(range.second);
22810 template <
typename T>
22813 T* begin =
const_cast<T*
>(r.
begin());
22814 T* end =
const_cast<T*
>(r.
end());
22818 template <
typename T>
22821 T* begin =
const_cast<T*
>(r.
begin());
22822 T* end =
const_cast<T*
>(r.
end());
22833 std::fill(const_cast<char*>(s.data()),const_cast<char*>(s.data() + s.size()), v);
22836 inline void fill(
const std::pair<const char*,const char*>& range,
char v)
22838 char* begin =
const_cast<char*
>(range.first);
22839 char* end =
const_cast<char*
>(range.second);
22843 template <
typename T>
22846 char* begin =
const_cast<char*
>(r.
begin());
22847 char* end =
const_cast<char*
>(r.
end());
22853 char* begin =
const_cast<char*
>(range.first);
22854 char* end =
const_cast<char*
>(range.second);
22858 template <
typename T,
22859 typename Allocator,
22860 template <
typename,
typename>
class Sequence>
22861 inline void fill(Sequence<T,Allocator>& seq,
const T& t)
22865 fill_n(seq.begin(),seq.size(),t);
22870 template <
typename CharType>
22876 : pair_block_delimiter(0),
22884 template <
typename KeyValueMap>
22892 template <
typename Options>
22896 pair_block_sdp_(options_.pair_block_delimiter),
22897 pair_delimiter_sdp_(options_.pair_delimiter)
22899 pair_list_.reserve(strtk::one_kilobyte);
22902 template <
typename T>
22905 return kv_map_.register_keyvalue(key,t);
22910 if (!ignore_failures)
22912 const std::size_t pair_count =
split(pair_block_sdp_,
22915 pair_list_.begin());
22916 if (0 == pair_count)
22922 for (std::size_t i = 0; i < pair_count; ++i)
22928 pair_delimiter_sdp_,
22929 key_range,value_range))
22931 else if (!kv_map_(key_range,value_range))
22938 parse_failures_ = 0;
22939 pair_token_processor processor(*
this);
22940 split(pair_block_sdp_,
22950 return operator()(strtk::make_pair<range_type::first_type>(s),ignore_failures);
22955 return parse_failures_;
22960 class pair_token_processor
22968 inline void operator()(
const range_type& r)
22970 if (r.first == r.second)
22973 parser_.pair_delimiter_sdp_,
22977 if (!parser_.kv_map_(key_range,value_range))
22978 ++parser_.parse_failures_;
22981 ++parser_.parse_failures_;
22986 pair_token_processor operator=(
const pair_token_processor&);
22988 parser<KeyValueMap>& parser_;
22989 range_type key_range;
22990 range_type value_range;
22993 options<char_type> options_;
22994 std::size_t parse_failures_;
22995 KeyValueMap kv_map_;
22996 single_delimiter_predicate<char_type> pair_block_sdp_;
22997 single_delimiter_predicate<char_type> pair_delimiter_sdp_;
22998 std::vector<range_type> pair_list_;
23005 typedef unsigned char char_type;
23022 template <
typename Options>
23031 template <
typename Range>
23032 inline bool operator()(
const Range& key_range,
const Range& value_range)
23034 std::size_t key = 0;
23037 if (key >= value_lut_.size())
23043 return v(value_range);
23046 template <
typename T>
23049 if (key < value_lut_.size())
23064 std::vector<strtk::util::value> value_lut_;
23069 template <
typename Range,
typename KType>
23078 template <
typename Range>
23083 return std::string(key_range.first,key_range.second);
23087 template <
typename Range>
23092 unsigned int result = 0;
23096 return std::numeric_limits<unsigned int>::max();
23102 template <
typename Range>
23110 template <
typename KeyType,
23111 typename MapType = std::map<KeyType,strtk::util::value>,
23112 typename KeyValidator = details::no_op_validator,
23113 typename ValueValidator = details::no_op_validator>
23123 template <
typename Options>
23130 template <
typename Range>
23131 inline bool operator()(
const Range& key_range,
const Range& value_range)
23133 if (!key_validator_(key_range))
23135 if (!val_validator_(value_range))
23138 if (value_map_.end() == itr)
23144 return v(value_range);
23147 template <
typename T>
23160 map_type value_map_;
23161 key_validator_type key_validator_;
23162 value_validator_type val_validator_;
23173 static inline std::ostream& operator<<(std::ostream& os,
23176 os <<
std::string((*range).first,(*range).second);
23180 static inline std::ostream&
operator<<(std::ostream& os,
23183 os <<
std::string((*range).first,(*range).second);
23187 static inline std::ostream&
operator<<(std::ostream& os,
23190 os <<
std::string((*range).first,(*range).second);
23194 #define strtk_register_pair_to_ostream(Iterator)\
23195 static inline std::ostream& operator<<(std::ostream& os, const std::pair<Iterator,Iterator>& range)\
23196 { os << std::string(range.first,range.second); return os; }\
23197 static inline std::ostream& operator<<(std::ostream& os, std::pair<Iterator,Iterator>& range)\
23198 { os << std::string(range.first,range.second); return os; }\
23209 #undef strtk_register_pair_to_ostream
23217 #ifndef WIN32_LEAN_AND_MEAN
23218 #define WIN32_LEAN_AND_MEAN
23220 #include <windows.h>
23222 #include <sys/time.h>
23223 #include <sys/types.h>
23237 QueryPerformanceFrequency(&clock_frequency_);
23240 inline void start()
23243 QueryPerformanceCounter(&start_time_);
23248 QueryPerformanceCounter(&stop_time_);
23252 inline double time()
const
23254 return (1.0 * (stop_time_.QuadPart - start_time_.QuadPart)) / (1.0 * clock_frequency_.QuadPart);
23262 start_time_.tv_sec = 0;
23263 start_time_.tv_usec = 0;
23264 stop_time_.tv_sec = 0;
23265 stop_time_.tv_usec = 0;
23271 gettimeofday(&start_time_,0);
23276 gettimeofday(&stop_time_, 0);
23284 if (stop_time_.tv_sec >= start_time_.tv_sec)
23286 return 1000000 * (stop_time_.tv_sec - start_time_.tv_sec ) +
23287 (stop_time_.tv_usec - start_time_.tv_usec);
23290 return std::numeric_limits<unsigned long long int>::max();
23293 return std::numeric_limits<unsigned long long int>::max();
23298 return usec_time() * 0.000001;
23313 LARGE_INTEGER start_time_;
23314 LARGE_INTEGER stop_time_;
23315 LARGE_INTEGER clock_frequency_;
23317 struct timeval start_time_;
23318 struct timeval stop_time_;
23327 : time_value_(time_value)
23335 time_value_ = t_.time();
23343 double& time_value_;
23349 namespace information
23351 static const char* library =
"String Toolkit";
23352 static const char* version =
"2.71828182845904523536028747135266249775724709369";
23353 static const char* date =
"20130126";
std::size_t for_each_line_n(std::istream &stream, const std::size_t &n, Function function, const std::size_t &buffer_size=one_kilobyte)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, T0 &t0, T1 &t1, T2 &t2) const
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5 >, 6 > csb_t
inserter_with_valuetype_iterator & operator++()
char operator()(const char c) const
bool range_only_contains(Predicate predicate, const InputIterator begin, const InputIterator end)
bool extract_column_checked(const std::size_t &index, OutputIterator out) const
void operator()(const std::pair< Iterator, Iterator > &r) const
bool sequential_partition(const row_range_t &row_range, TransitionPredicate p, Function f)
std::size_t file_size(const std::string &file_name)
static bool process(Iterator itr)
strtk::tokenizer< string_iterator_type, DelimiterPredicate > type
bool contains(const T &t) const
bool extract_column(const row_range_t &row_range, const std::size_t &index, OutputIterator out) const
column_list_impl< 3 > column_list_t
bool load(const std::string &file_name, const token_grid::options &options)
void skip_while_matching(Iterator &itr, const Iterator &end, const MatchPredicate &predicate)
void parse_checked(std::stack< T, Container > &stack) const
void operator()(const std::pair< Iterator, Iterator > &r) const
token_grid(const std::string &input_buffer, const std::size_t &input_buffer_size, const std::string &column_delimiters=",;|\t ", const std::string &row_delimiters="\n\r")
multiple_delimiter_predicate(const Iterator begin, const Iterator end)
static bool process(Iterator itr)
std::deque< row_index_range_t > row_index_t
bool operator()(const Sequence< T, Allocator > &sequence) const
const_iterator_ref begin() const
static unsigned int transform(const Range &key_range)
bool operator()(const T(&data)[N], const bool write_length=false)
sink_type< std::queue< T > > type
std::size_t index_of(const std::string &pattern, const std::string &data)
strtk_register_type_name(signed char) strtk_register_type_name(unsigned char) strtk_register_type_name(short) strtk_register_type_name(int) strtk_register_type_name(long) strtk_register_type_name(long long) strtk_register_type_name(unsigned short) strtk_register_type_name(unsigned int) strtk_register_type_name(unsigned long) strtk_register_type_name(unsigned long long int) strtk_register_type_name(double) strtk_register_type_name(float) strtk_register_type_name(long double) strtk_register_type_name(std
virtual void compute_indices(const bloom_type &hash, std::size_t &bit_index, std::size_t &bit) const
static void process(Iterator itr, T &t)
void swap_inplace(std::string &s, const std::size_t &i0, const std::size_t &i1)
void operator()(const std::pair< Iterator, Iterator > &r)
conv_to_lcase_impl & ref()
void reset(const bool clear_buffer=false)
hex_to_number_sink & operator=(const hex_to_number_sink &hns)
column_selector_impl< T > type
range_to_ptr_type_iterator< T > range_to_ptr_type(T *pointer, std::size_t &insert_count)
bool files_identical(const std::string &file_name1, const std::string &file_name2)
static void process(Iterator itr, T &t)
bool match(const Iterator pattern_begin, const Iterator pattern_end, const Iterator data_begin, const Iterator data_end, const typename std::iterator_traits< Iterator >::value_type &zero_or_more, const typename std::iterator_traits< Iterator >::value_type &zero_or_one)
tokenizer::iterator_type range_t
inrange_impl(T &t, const T &low, const T &hi)
void hash(const Iterator itr, std::size_t length, unsigned int &hash_value)
std::size_t split_regex(const boost::regex &delimiter_expression, const InputIterator begin, const InputIterator end, OutputIterator out, const regex_match_mode::type mode=regex_match_mode::match_all)
range_to_ptr_type_iterator & operator=(const std::string &s)
std::size_t parse_line_n(std::ifstream &stream, const std::string &delimiters, const std::size_t &n, Sequence< T, Allocator > &sequence, const split_options::type &split_option=split_options::compress_delimiters)
static bool cmp(ptr, ptr)
void parse_checked(std::set< T, Comparator, Allocator > &set) const
bool operator()(const Range &key_range, const Range &value_range)
column_list_impl< 4 > column_list_t
void insert(const std::string &key)
filter_on_wildcard_match(const std::string &match_pattern, OutputPredicate &predicate, bool allow_through_on_match=true)
combination_iterator(const std::size_t &k, iterator begin, iterator end, const bool sorted=true)
#define strtk_parse_col_begin()
container_adder(std::list< T, Allocator > &list)
void parse_checked(std::priority_queue< T, Container, Comparator > &priority_queue) const
inserter_with_valuetype_iterator< Set > inserter_with_valuetype(Set &set_)
bool operator()(const Iterator begin, const Iterator end) const
back_inserter_with_valuetype_iterator & operator*()
bool type_to_string_converter_impl(const T &t, std::string &s, not_supported_type_tag)
bool operator()(const std::string &str) const
range_to_type_push_inserter_iterator & operator=(const range_to_type_push_inserter_iterator &it)
bool clear_array(T(&a)[N], const T &t, const std::size_t &length=N)
std::string as_string(const adapter< const unsigned char > &a)
static void process(Iterator, T &t)
#define register_stl_container2(C)
bool operator()(InputIterator begin, InputIterator end)
bool operator()(const type &)
void for_each_combination_conditional(Iterator begin, Iterator end, const std::size_t &size, Function function)
std::size_t parse(const char *delimiters, Sequence< T, Allocator > &seq) const
bool parse_with_index(const std::size_t &col, T &t) const
void nth_combination_sequence(unsigned long long int n, const std::size_t &r, const std::size_t &k, OutputIterator out, const bool complete_index=true)
std::size_t position() const
static bool process(Iterator itr)
bool twoway_bitwise_interleave(const unsigned char *begin1, const unsigned char *end1, const unsigned char *begin2, const unsigned char *end2, unsigned char *out)
details::column_list_impl< 12 > column_list(const std::size_t &idx0, const std::size_t &idx1, const std::size_t &idx2, const std::size_t &idx3, const std::size_t &idx4, const std::size_t &idx5, const std::size_t &idx6, const std::size_t &idx7, const std::size_t &idx8, const std::size_t &idx9, const std::size_t &idx10, const std::size_t &idx11)
ext_string & remove_leading(const std::string &removal_set)
range_to_type_back_inserter_iterator & operator=(const std::pair< Iterator, Iterator > &r)
bool ends_with(const InputIterator pattern_begin, const InputIterator pattern_end, const InputIterator begin, const InputIterator end)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, const std::size_t &col5, const std::size_t &col6, const std::size_t &col7, const std::size_t &col8, const std::size_t &col9, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9) const
static void process(Iterator itr, T &t)
bool is_letter(const char c)
void construct(std::string &output, const std::string &delimiter, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8, const T9 &t9, const T10 &t10, const T11 &t11, const T12 &t12)
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11 >, 12 > csb_t
bool operator()(const range_type &data, const bool ignore_failures=false)
void reset(const bool clear_buffer=false)
combination_iterator(const std::size_t &k, Sequence< T, Allocator > &seq, const bool sorted=true)
bool for_each_permutation_conditional(Iterator begin, Iterator end, Function function)
bool find_prefix(prefix< std::string::const_iterator, Value > &trie, const char *key)
column_selector_base< Cli, N > csb_t
combination_iterator & operator+=(const int inc)
sink_type< std::priority_queue< T > > type
bool parse(InputIterator begin, InputIterator end)
bool operator==(const combination_iterator &itr) const
multiple_delimiter_predicate(const T *d_begin, const T *d_end)
unsigned long long int minimum_size
unsigned long long int random_seed
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
details::index_remover_impl< Allocator, Sequence > index_remover(const Sequence< std::size_t, Allocator > &sequence)
void extract_column_checked(const std::size_t &index, std::multiset< T, Comparator, Allocator > &multiset) const
#define strtk_parse_columns_impl(NN)
void operator()(const Iterator begin, const Iterator end)
std::size_t current_index
static KType transform(const Range &)
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2)
bool operator()(const InputIterator begin, const InputIterator end)
bool operator()(const std::pair< InputIterator, InputIterator > &r) const
bool operator()(const Iterator begin, const Iterator end) const
combination_iterator(iterator end)
fill_array_impl & set_data(char *data)
bool join_row(const std::size_t &row, Predicate predicate, const std::string &delimiter, std::string &result)
double effective_fpp() const
std::pair< Iterator, Iterator > type
sink_type & operator()(Container &container, const std::string &delimiters="", const split_options::type &split_option=split_options::compress_delimiters)
const unsigned char * ptr
bool operator()(const T &input, const std::size_t &size, const padding_mode pmode, const char padding= ' ')
optimal_parameters_t optimal_parameters
sink_type & count(const std::size_t &element_count=std::numeric_limits< std::size_t >::max())
base64_to_number_sink & operator=(const std::string &s)
void set_value(const std::string &s)
static bool execute(InputIterator begin, InputIterator end, const std::string &rem_chars, std::size_t mode, std::string &t)
range_to_ptr_type_iterator operator++(int)
std::pair< iterator_t, iterator_t > range_t
column_selector_impl< T, T, T, T, T, T, T, T, T > type
column_list_impl< 8 > column_list_t
bool operator()(const T &d) const
bool parse(std::set< T, Comparator, Allocator > &set) const
std::size_t row_count() const
csii_t & operator=(const std::pair< Iterator, Iterator > &r)
std::string remove_duplicates(const std::string &str)
bool operator()(InputIterator begin, InputIterator end)
col_range_t all_columns() const
counting_back_inserter_iterator< T > counting_back_inserter(std::size_t &counter_)
void assign(const std::string &s) const
bool find(const key_iterator_t begin, const key_iterator_t end, value_t &v) const
void min_max_of_cont(const Sequence< T, Allocator > &sequence, T &min_value, T &max_value)
const std::string::value_type * string_iterator_type
void reverse(std::string &s)
static void process(Iterator itr, T &t)
multiple_char_delimiter_predicate(const std::string &s)
inserter_with_valuetype_iterator & operator=(const typename Set::value_type &v)
scoped_timer(double &time_value)
std::size_t amount_written() const
const char * first_non_repeated_char(const char *begin, const char *end)
range_to_type_back_inserter_iterator & operator*()
#define strtk_parse_col_token_seq(Index)
static void process(Iterator itr, T &t)
static bool process(Iterator itr)
unsigned long long int table_size_
void set_pattern(const std::string &s)
void random_permutation(const Iterator begin, const Iterator end, RandomNumberGenerator &rng, OutputIterator out)
column_list_impl< 12 > column_list_t
column_list_impl< 2 > column_list_t
bool operator()(const std::string &str) const
void insert(const key_iterator_t begin, const key_iterator_t end, const value_t &v)
std::size_t parse_n(const std::size_t &n, Sequence< T, Allocator > &sequence) const
trim_impl(const std::size_t mode, T &t, const std::string &rem_chars=" ")
adapter(T *const begin, const std::size_t length)
range_to_type_push_inserter_iterator & operator++()
std::string center(const std::size_t &width, const T &t)
range_to_type_back_inserter_iterator(const range_to_type_back_inserter_iterator &it)
bool match_atleast_n_consecutive_values(const std::size_t n, Predicate p, Iterator itr, const Iterator end)
void join_if(std::string &output, const std::string &delimiter, Predicate predicate, const InputIterator begin, const InputIterator end)
std::size_t write_to_text_file(std::ostream &stream, const Sequence< T, Allocator > &sequence, const std::string &delimiter="")
column_selector_impl< T, T, T, T > type
bool native_to_be(const T &input)
bool join_column(const std::size_t &col, const row_range_t &row_range, Predicate predicate, const std::string &delimiter, std::string &result) const
column_list_impl< 10 > column_list_t
strtk_register_iostream_precision(float) strtk_register_iostream_precision(double) strtk_register_iostream_precision(long double) template< typename Iterator
void operator()(const std::pair< Iterator, Iterator > &range) const
std::string remove_duplicates_inplace(std::string &str)
std::size_t for_each_row(const row_range_t &row_range, Function f) const
bool operator()(const std::set< T, Comparator, Allocator > &set)
void register_value(T &t)
bool operator()(const Iterator begin, const Iterator end) const
range_to_type_back_inserter_iterator & operator++()
bool register_keyvalue(const key_type &key, T &t)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
trie::prefix< KeyIterator, ValueType > std_string
conv_to_ucase_impl & ref()
void cut(const std::size_t &r0, const std::size_t &r1, const InputIterator begin, InputIterator end, OutputIterator out)
void insert(const InputIterator begin, const InputIterator end)
std::size_t for_each_column(Function f) const
bool operator()(T *&data, uint32_t &length, const bool read_length=true)
void remove_pattern(const std::string &s, const std::string &p, std::string &n)
column_selector_impl< T, T, T, T, T > type
std::size_t split_on_consecutive(const std::size_t n, Predicate p, char *begin, char *end, OutputIterator out, const bool stateful_predicate=false)
std::size_t parse_n_stl_container_proxy(const InputIterator begin, const InputIterator end, const std::string &delimiters, const std::size_t &n, Sequence< T, Allocator > &sequence, const split_options::type &split_option=split_options::compress_delimiters)
bool operator()(const T *data, const uint8_t &length, const bool write_length=true)
std::pair< Iterator, Iterator > range_type
void delete_all(std::multiset< T *, Comparator, Allocator > &cont)
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, T0 &t0, T1 &t1) const
trie::prefix< char *, ValueType > char_ptr
#define strtk_register_sink_type_tag(T)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
details::range_type< Iterator >::type find_n_consecutive(const std::size_t n, find_type::type type, find_mode::type mode, typename details::range_type< Iterator >::type range)
std::size_t amount_read()
static void process(Iterator, T &)
strtk_register_rand_int_type_tag(char) strtk_register_rand_int_type_tag(unsigned char) strtk_register_rand_int_type_tag(short) strtk_register_rand_int_type_tag(int) strtk_register_rand_int_type_tag(long) strtk_register_rand_int_type_tag(unsigned short) strtk_register_rand_int_type_tag(unsigned int) strtk_register_rand_int_type_tag(unsigned long) strtk_register_rand_real_type_tag(float) strtk_register_rand_real_type_tag(double) strtk_register_rand_real_type_tag(long double) template< typename T
push_inserter_iterator< Container > push_inserter(Container &c)
void operator()(const T &t)
bool operator()(T(&output)[N])
range_to_type_inserter_iterator & operator=(const std::pair< Iterator, Iterator > &r)
bool join_column(const std::size_t &col, const row_range_t &row_range, const std::string &delimiter, std::string &result) const
std::size_t load_from_text_file(std::istream &stream, Sequence< T, Allocator > &sequence, const std::size_t &buffer_size=one_kilobyte)
range_to_type_back_inserter_iterator(Sequence &sequence)
bool operator()(const T &d) const
hex_to_string_sink & operator=(const std::pair< InputIterator, InputIterator > &s)
bool rewind(const std::size_t &n_bytes)
unsigned int maximum_number_of_hashes
void nth_permutation_sequence(std::size_t n, const std::size_t k, OutputIterator out)
void convert_to_lowercase(unsigned char *begin, unsigned char *end)
std::size_t element_count() const
column_list_impl< 4 > column_list_t
push_inserter_iterator< Container > & operator=(typename Container::const_reference v)
bool all_digits_check(Iterator begin, Iterator end)
bool operator()(reader &r)
column_selector_impl< T, T, T > type
build_string(const std::size_t &initial_size=64)
offset_predicate(const int offset_list[], const bool rotate=false)
~multiple_delimiter_predicate()
column_list_impl< 5 > column_list_t
column_list_impl< 8 > column_list_t
void bitwise_transform(const bitwise_operation::type &operation, const unsigned char *begin1, const unsigned char *end1, const unsigned char *begin2, unsigned char *out)
std::size_t raw_length(const std::size_t &column_index) const
std::size_t parse_stl_container_proxy(const InputIterator begin, const InputIterator end, const std::string &delimiters, Sequence< T, Allocator > &sequence, const split_options::type &split_option=split_options::compress_delimiters)
bool operator()(const T &)
details::column_list_impl< N > column_list_t
static void process(Iterator itr, T &t)
bool string_to_type_converter(const Iterator begin, const Iterator end, T &t)
container_adder(std::set< T, Comparator, Allocator > &set)
hex_to_string_sink(std::string &s)
#define register_stl_container1(C)
void enforce_column_count(const row_range_t &row_range, const std::size_t &column_count)
#define strtk_register_supported_iterator_type(T)
void generate_random_values(const std::size_t &count, const T &min, const T &max, OutputIterator out, const std::size_t &seed=magic_seed, const std::size_t &pregen=0)
sink_type< std::deque< T > > type
column_list_impl< 3 > column_list_t
counting_back_inserter_iterator operator++(int)
bool operator()(strtk::binary::reader &reader)
details::conv_to_ucase_impl as_ucase(std::string &s)
static bool cmp(ptr c1, ptr c2)
bool extract_column_checked(const row_range_t &row_range, const std::size_t &index, OutputIterator out) const
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4) const
counting_back_inserter_iterator & operator*()
hex_to_number_sink(const hex_to_number_sink &hns)
static bool execute(InputIterator begin, InputIterator end, const std::string &rem_chars, std::size_t mode, Type &t)
tokenizer_iterator< Iterator, DelimiterPredicate > iterator
details::inrange_impl< T > inrange(T &t, const T0 &low, const T1 &hi)
std::size_t parse(const std::string &delimiters, Sequence< T, Allocator > &seq) const
void generate_random_data(unsigned char *data, std::size_t length, unsigned int pre_gen_cnt=0, unsigned int seed=magic_seed)
multiple_delimiter_predicate(const T d[], const std::size_t &length)
offset_predicate< 12 > offsets(const int &v1, const int &v2, const int &v3, const int &v4, const int &v5, const int &v6, const int &v7, const int &v8, const int &v9, const int &v10, const int &v11, const int &v12, const bool &rotate=false)
functional_inserter_iterator & operator=(const T &t)
hex_to_number_sink & operator=(const std::pair< InputIterator, InputIterator > &s)
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6)
functional_inserter_iterator(Function function)
token_grid(const unsigned char *input_buffer, const std::size_t &input_buffer_size, const token_grid::options &options)
static bool cmp(ptr c1, ptr c2)
multiple_char_delimiter_predicate(const Iterator begin, const Iterator end)
filter_on_match(const std::string *begin, const std::string *end, OutputPredicate predicate, bool case_insensitive, bool allow_through_on_match=true)
void fill(Sequence< T, Allocator > &seq, const T &t)
bool operator()(std::string &output)
static bool process(Iterator itr)
const unsigned char * iterator_t
bool load(unsigned char *buffer, const std::size_t buffer_size, const token_grid::options &options)
ext_string & remove_trailing(const Predicate &p)
bool parse(const col_range_t &range, std::set< T, Comparator, Allocator > &set) const
#define strtk_register_stdstring_range_type_tag(T)
void replicate_inplace(const std::size_t &n, std::string &str)
ignore_token & operator=(const std::string &)
push_inserter_iterator & operator=(const push_inserter_iterator &itr)
static bool process(Iterator itr)
void iota(Iterator begin, Iterator end, T value)
static bool process(Iterator itr)
bool add(InputIterator begin, InputIterator end) const
unsigned int inserted_element_count_
std::string translate(const translation_table &trans_table, const std::string &s)
void numeric_convert(Iterator itr, T &t, const bool digit_check=false)
bool operator==(const value &v) const
push_inserter_iterator< Container > & operator++()
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
bool operator()(const Iterator begin, const Iterator end)
void replicate(const std::size_t &n, const std::string &str, std::string &output)
colsel_value_list & cvl()
static void process(Iterator itr, T &t)
bool operator()(InputIterator begin, InputIterator end)
unsigned int minimum_number_of_hashes
options & set_row_split_option(const split_options::type &option)
token_grid(const std::string &file_name, const token_grid::options &options)
bool operator()(std::ifstream &stream, const std::size_t &length)
bool operator()(const unsigned char &c) const
ext_string operator-(const ext_string &s, const std::string &pattern)
std::size_t find_all(const Iterator pattern_begin, const Iterator pattern_end, const Iterator begin, const Iterator end, OutputIterator out)
std::iterator_traits< Iterator >::value_type value_type
inserter_with_valuetype_iterator(Set &set)
ext_string & remove_trailing(const std::string &removal_set)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, const std::size_t &col5, const std::size_t &col6, const std::size_t &col7, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7) const
void clear(std::priority_queue< T, Container, Comparator > &priority_queue)
bool operator()(const std::pair< Iterator, Iterator > &range) const
bool operator==(const T &t)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
bloom_type hash_ap(const unsigned char *begin, std::size_t remaining_length, bloom_type hash) const
bool string_to_type_converter_impl(Iterator &itr, const Iterator end, strtk::util::semantic_action_impl &result, semantic_action_type_tag)
column_selector_impl< T, T, T, T, T, T, T, T, T, T > type
bool operator()(std::ifstream &stream)
void replace(const typename std::iterator_traits< Iterator >::value_type &c1, const typename std::iterator_traits< Iterator >::value_type &c2, const Iterator begin, const Iterator end)
range_t token(const unsigned int &row, const std::size_t &col) const
base64_to_number_sink(T &t)
bool operator()(T *&data, uint64_t &length, const bool read_length=true)
std::size_t remove_consecutives_inplace(Predicate predicate, Iterator begin, Iterator end)
semantic_action_impl & ref()
container_adder(std::deque< T, Allocator > &deq)
counting_back_inserter_iterator & operator=(const T &)
bool is_all_letters(const std::string &s)
column_list_impl< 1 > column_list_t
fill_array_impl(unsigned char *data, const std::size_t &size)
void combine_discontinuous(Iterator first1, Iterator last1, typename std::iterator_traits< Iterator >::difference_type d1, Iterator first2, Iterator last2, typename std::iterator_traits< Iterator >::difference_type d2, Function &f, typename std::iterator_traits< Iterator >::difference_type d=0)
#define strtk_register_set_type_name(Type)
hex_to_string_sink & operator=(const std::string &s)
functional_inserter_iterator & operator*()
void as_string(std::string &out) const
static bool process(Iterator itr)
std::size_t col_list_index_
sink_type(Container &container, const std::string &delimiters, const split_options::type &split_option=split_options::compress_delimiters)
std::size_t select_k_randomly(const Iterator begin, const Iterator end, const std::size_t k, OutputIterator out, RandomNumberGenerator &rng)
Tag bool string_to_type_converter_impl(Iterator &begin, const Iterator end, T &t, not_supported_type_tag)
column_selector_base< column_selector_impl< T0, T1, T2 >, 3 > csb_t
range_type current_combination_
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
sink_type< std::stack< T > > type
sequence_t::const_iterator itr_
bool operator()(InputIterator begin, InputIterator end) const
std::size_t accumulate_column(const std::size_t &col, const row_range_t &row_range, T &result) const
back_inserter_with_valuetype_iterator & operator=(const typename Sequence::value_type &v)
static bool process(Iterator itr)
range_to_type_inserter_iterator< Set > range_to_type_inserter(Set &set)
#define strtk_register_rand_real_type_tag(T)
bool operator()(InputIterator begin, InputIterator end)
bool operator()(const std::set< T, Comparator, Allocator > &set) const
void operator()(const Iterator begin, const Iterator end)
std::ostream & operator<<(std::ostream &out, const LogHistogram &hist)
ext_string(const ext_string &es)
column_selector_iterator_impl< InputIterator, N > csii_t
bool parse_line(std::ifstream &stream, const std::string &delimiters, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11, T12 &t12)
key_map< std::string > stringkey_map
details::trim_impl< T > trim_leading(const std::string &rem_chars, T &t)
container_adder(std::stack< T, Container > &stack)
std::size_t split_on_consecutive_n(const std::size_t &n, const std::size_t &m, const find_type::type type, const find_mode::type mode, char *begin, char *end, OutputIterator out)
void make_value_list(const std::multimap< Key, T, Comparator, MapAllocator > &map, const Key &key, Sequence< T, SequenceAllocator > &sequence)
bool parse(T0 &t0, T1 &t1) const
bool operator()(const std::set< T, Comparator, Allocator > &set) const
filter(const filter &filter)
void join(std::string &output, const std::string &delimiter, const InputIterator begin, const InputIterator end)
static void process(Iterator itr, T &t)
void for_each_combination(Iterator begin, Iterator end, const std::size_t &size, Function function)
std::size_t index_list[N]
std::size_t accumulate_row(const std::size_t &row, T &result) const
bool parse(const col_range_t &range, std::stack< T, Container > &stack) const
bool parse(std::multiset< T, Comparator, Allocator > &multiset) const
bool extract_column(const row_range_t &row_range, const std::size_t &index0, const std::size_t &index1, const std::size_t &index2, const std::size_t &index3, OutputIterator0 out0, OutputIterator1 out1, OutputIterator2 out2, OutputIterator3 out3) const
Sequence::value_type value_type
KeyValidator key_validator_type
void insert_inplace(std::string &s, const std::size_t &index, const char c)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
unsigned long long int random_seed_
static ext_string all_lowercase_letters()
static bool cmp(ptr c1, ptr c2)
bool parse(std::priority_queue< T, Container, Comparator > &priority_queue) const
range_type< Iterator >::type find_exactly_n_consecutive_values(const std::size_t n, Predicate p, Iterator itr, const Iterator end, const bool stateful_predicate=false)
void bracketize(std::string &output, const std::string &pre, const std::string &post, const InputIterator begin, const InputIterator end)
bool compress(const double &percentage)
strtk::details::column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >::csb_t column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >, 11 > csb_t
filter_non_empty_range(OutputIterator out)
void operator()(const typename Sequence::value_type &v)
void for_each_permutation(Iterator begin, Iterator end, Function function)
fill_array_impl & set_data(unsigned char *data)
column_selector_impl< T, T, T, T, T, T, T > type
counting_back_inserter_iterator(std::size_t &counter)
bool is_digit(const char c)
static void process(Iterator itr, T &t)
range_to_type_inserter_iterator(Set &set)
bool extract_column(const std::size_t &index, OutputIterator out) const
bool register_keyvalue(const key_type &key, T &t)
#define strtk_register_base64_type_tag(T)
std::size_t hamming_distance(const unsigned char *begin1, const unsigned char *end1, const unsigned char *begin2, const unsigned char *end2)
trie::prefix< KeyIterator, ValueType > type
range_type operator*() const
void insert(const char *data, const std::size_t &length)
adapter< const char > string
void insert(const unsigned char *key_begin, const std::size_t &length)
bool is_letter_or_digit(const char c)
bool join_column(const std::size_t &col, const std::string &delimiter, std::string &result) const
attribute & operator=(const T &t)
row_range_t all_rows() const
base64_to_number_sink(const base64_to_number_sink &bns)
ignore_token & operator=(const std::pair< InputIterator, InputIterator > &)
std::size_t for_each_line(std::istream &stream, Function function, const std::size_t &buffer_size=one_kilobyte)
#define strtk_register_sequence_iterator_type(sequence)
InputIterator copy_until(Predicate predicate, const InputIterator begin, const InputIterator end, OutputIterator out)
range_to_ptr_type_iterator & operator*()
std::size_t for_each_line_n_conditional(std::istream &stream, const std::size_t &n, Function function, const std::size_t &buffer_size=one_kilobyte)
token_grid(const unsigned char *input_buffer, const std::size_t &input_buffer_size, const std::string &column_delimiters=",|;\t", const std::string &row_delimiters="\n\r")
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
ext_string operator*(const std::size_t &n, const ext_string &s)
std::iterator_traits< KeyIterator >::value_type key_value_t
functional_inserter_iterator operator++(int)
details::trim_impl< T > trim(const std::string &rem_chars, T &t)
bool is_all_digits(const std::string &s)
bool match_exactly_n_consecutive_values(const std::size_t n, Predicate p, Iterator itr, const Iterator end)
std::size_t inserter(Inserter ins, const InputIterator begin, const InputIterator end, OutputIterator out)
bool operator()(const std::string &input)
const T & operator[](const std::size_t &index) const
functional_inserter_iterator< Function > functional_inserter(Function function)
static void process(Iterator itr, T &t)
details::container_adder type
bool contains(const std::string &key) const
unsigned char * bit_table_
ext_string & remove_leading(const Predicate &p)
column_selector_base< column_selector_impl< T0, T1, T2, T3 >, 4 > csb_t
bool type_to_string_converter_impl(const strtk::util::value &v, std::string &result, value_type_tag)
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8) const
bool operator()(const InputIterator begin, const InputIterator end)
std::vector< bloom_type > salt_
bool is_lowercase_letter(const char c)
void push_back(std::multiset< T, Comparator, Allocator > &set, const T &v1)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, const std::size_t &col5, const std::size_t &col6, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6) const
bool memcmp_n(details::ptr c1, details::ptr c2)
ext_string(const char *s)
void parse_checked(std::queue< T, Container > &queue) const
std::size_t for_each_row(Function f) const
std::string & as_string()
base64_to_number_sink & operator=(const std::pair< InputIterator, InputIterator > &s)
bool operator()(const Iterator begin, const Iterator end) const
void sort(std::string &s)
column_list_impl< 2 > column_list_t
range_type< Iterator >::type find_n_consecutive_values(const std::size_t n, find_mode::type mode, Predicate p, Iterator itr, const Iterator end)
void extract_column_checked(const std::size_t &index, Sequence< T, Allocator > &sequence) const
bool operator()(std::vector< T, Allocator > &vec)
interval_inserter(const std::size_t &interval, const T &t)
bool parse(const col_range_t &range, std::multiset< T, Comparator, Allocator > &multiset) const
bool operator()(InputIterator begin, InputIterator end)
static void process(Iterator itr, T &t)
bool operator()(const Sequence< T, Allocator > &seq)
const column_list_t & column_list_
static bool process(Iterator itr)
combination_iterator(const std::size_t &k, std::string &str, const bool sorted=true)
unsigned int number_of_hashes
std::size_t parse_n(const InputIterator begin, const InputIterator end, const std::string &delimiters, const std::size_t &n, Sequence< T, Allocator > &sequence, const split_options::type &split_option=split_options::compress_delimiters)
range_to_type_back_inserter_iterator & operator=(const std::string &s)
range_to_ptr_type_iterator & operator++()
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
void min_max_of_range(const InputIterator begin, const InputIterator end, typename std::iterator_traits< InputIterator >::value_type &min_value, typename std::iterator_traits< InputIterator >::value_type &max_value)
unsigned long long int raw_table_size_
static bool process(Iterator)
std::size_t remove_trailing(Predicate predicate, Iterator begin, Iterator end)
void parse_checked(Sequence< T, Allocator > &sequence) const
static bool process(Iterator itr)
bool parse(const InputIterator begin, const InputIterator end, const std::string &delimiters, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11, T12 &t12)
virtual unsigned long long int size() const
node< KeyIterator, value_t > node_t
details::column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > column_selector(const details::column_list_impl< 11 > &col_list, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11)
tokenizer(const Iterator begin, const Iterator end, const DelimiterPredicate &predicate, const tokenize_options::type tokenize_options=tokenize_options::default_mode)
bool operator()(const std::vector< T, Allocator > &vec)
char_type pair_block_delimiter
std::size_t remove_inplace(Predicate predicate, Iterator begin, Iterator end)
container_adder(std::vector< T, Allocator > &vec)
short_string_impl< size_type > & set(std::string &str)
bool imatch_char(const char c1, const char c2)
bool write_to_file(const std::string &file_name) const
static void process(Iterator itr, T &t)
details::iexpect_impl iexpect(const std::string &s)
range_to_ptr_type_iterator & operator=(const std::pair< Iterator, Iterator > &r)
filter(const parameters &p)
inserter_with_valuetype_iterator(const inserter_with_valuetype_iterator &itr)
reader(T *buffer, const std::size_t &buffer_length)
std::size_t min_column_count() const
virtual bool contains(const unsigned char *key_begin, const std::size_t length) const
semantic_action_impl(const Function &f)
counting_back_inserter_iterator(const counting_back_inserter_iterator &itr)
void numeric_convert(const std::string &s, T &t, const bool digit_check=false)
const_iterator_ref end() const
ignore_token_type_tag type
bool is_hex_digit(const char c)
sink_type(const std::string &delimiters, const split_options::type &split_option=split_options::compress_delimiters)
bool match_n_consecutive_values(const std::size_t n, find_mode::type mode, Predicate p, Iterator itr, const Iterator end)
std::size_t hamming_distance_elementwise(const Iterator begin1, const Iterator end1, const Iterator begin2, const Iterator end2)
like_impl(const std::string &s)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
token_grid(const char *input_buffer, const std::size_t &input_buffer_size, const token_grid::options &options)
void replace(const std::string &pattern, const std::string &replace_pattern)
static token_grid::options default_options()
semantic_action_impl semantic_action(Function &f)
bool operator()(const std::multiset< T, Comparator, Allocator > &multiset) const
translation_table(const std::string &itable, const std::string &otable)
void generate_unique_salt()
T & operator[](const std::size_t &index)
void clear(const bool force_delete_buffer=false)
std::size_t failure_count() const
bool parse(std::queue< T, Container > &queue) const
column_list_impl< 6 > column_list_t
bool operator()(const std::pair< InputIterator, InputIterator > &r) const
#define strtk_register_stl_container_to_string_conv_type_tag(T)
bool operator()(std::pair< T1, T2 > &p)
InputIterator contains_all(const InputIterator begin, const InputIterator end) const
static bool process(Iterator itr)
#define strtk_register_byte_type_tag(T)
bool bit_state(const std::size_t &index, const unsigned char *ptr)
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4)
token_grid(const std::string &input_buffer, const std::size_t &input_buffer_size, const token_grid::options &options)
bool parse(Sequence< T, Allocator > &sequence) const
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8 >, 9 > csb_t
void parse(OutputIterator out) const
range_to_ptr_type_iterator(const range_to_ptr_type_iterator &it)
std::size_t split_n(const DelimiterPredicate &delimiter, const Iterator begin, const Iterator end, const std::size_t &token_count, OutputIterator out, const split_options::type &split_option=split_options::default_mode)
unsigned long long int table_size
Container::value_type value_type
static void process(Iterator itr, T &t)
counting_back_inserter_iterator & operator++()
static bool process(Iterator itr)
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
void compute_block(Iterator itr, std::size_t &length, unsigned int &hash)
fill_array_impl & set(unsigned char *data, const std::size_t &size)
void compute_pod_hash(const char data[], unsigned int &hash)
adapter< T > type(const T *begin, const T *end)
bool operator()(const std::string &s) const
#define strtk_parse_col_end()
std::size_t strnlength(const char *s, const std::size_t &n)
short_string_impl(std::string &str)
void remove_leading_trailing(const std::string &rem_chars, std::string &s)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, const std::size_t &col5, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5) const
row_type row(const unsigned int &row_index) const
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
#define strtk_register_signed_type_tag(T)
void enforce_min_max_column_count(const std::size_t &min_column_count, const std::size_t &max_column_count)
Set::value_type value_type
column_selector_impl< T, T, T, T, T, T > type
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8)
base64_to_number_sink & operator=(const base64_to_number_sink &bns)
adapter(T *const begin, T *const end)
std::pair< Iterator1, Iterator2 > make_pair(const strtk::range::string &range)
bool operator()(std::set< T, Comparator, Allocator > &set)
#define strk_parse_col_seq
csb_t & operator=(const std::pair< Iterator, Iterator > &r)
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7) const
InputIterator copy_while(Predicate predicate, const InputIterator begin, const InputIterator end, OutputIterator out)
void cut_inplace(const std::size_t &r0, const std::size_t &r1, const Iterator begin, const Iterator end)
bool match_n_consecutive(const std::size_t n, find_type::type type, find_mode::type mode, typename details::range_type< Iterator >::type range)
container_adder(std::multiset< T, Comparator, Allocator > &multiset)
std::size_t accumulate_column(const std::size_t &col, Predicate p, T &result) const
bool operator()(Sequence< T, Allocator > &seq)
bool operator!=(const char *s, const attribute< std::string > &attrib)
adapter< typename Sequence< T, Allocator >::iterator > type(const Sequence< T, Allocator > &seq)
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5)
push_inserter_iterator(Container &container)
range_to_ptr_type_iterator & operator=(const range_to_ptr_type_iterator &it)
compressible_filter(const parameters &p)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4) const
bool remove_row_if(const row_range_t &row_range, Predicate predicate)
RandomNumberGenerator void generate_random_values_impl(const std::size_t &count, const T &min, const T &max, OutputIterator out, RandomNumberGenerator &rng, rand_int_type_tag)
Sequence< std::size_t, Allocator > sequence_t
semantic_action_type_tag type
column_list_impl< 6 > column_list_t
range_to_type_inserter_iterator & operator=(const range_to_type_inserter_iterator &it)
combination_iterator & operator++()
void create_nway_interleave_table(typename interleave_ary< n >::type table[256])
not_supported_type_tag type
bool signed_all_digits_check(Iterator begin, Iterator end)
unsigned long long int usec_time() const
std::size_t offset_splitter(const InputIterator begin, const InputIterator end, const OffsetPredicate &offset, OutputIterator out)
std::pair< string_iterator_type, string_iterator_type > iterator_type
details::expect_impl expect(const std::string &s)
bool imatch(const ext_string &es) const
bool negate(T &t, strtk::details::signed_type_tag)
push_inserter_iterator< Container > operator++(int)
std::size_t current_index_
functional_inserter_iterator(const functional_inserter_iterator &it)
column_list_impl< 1 > column_list_t
range_to_type_back_inserter_iterator & operator=(const range_to_type_back_inserter_iterator &it)
bool to_string(std::string &s) const
static ext_string all_digits()
bool be_to_native(T &output)
std::string column_delimiters
double false_positive_probability
void set_bit_low(const std::size_t &index, unsigned char *const ptr)
build_string & operator<<(const T &t)
bool operator()(const std::pair< Iterator, Iterator > &range) const
row_type(const std::size_t &index, const store &dsv_index)
bool operator()(InputIterator begin, InputIterator end)
bool operator()(const Sequence< T, Allocator > &sequence) const
value & operator=(const value &v)
range_to_type_push_inserter_iterator(Container &container)
void reverse(const std_string::iterator_type &range)
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4 >, 5 > csb_t
void assign(const std::string &s)
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3)
bool operator()(const T *data, const uint32_t &length, const bool write_length=true)
std::string as_uppercase(const std::string &str)
back_inserter_with_valuetype_iterator operator++(int)
const iterator const_iterator
void remove_empty_strings(Sequence< std::string, Allocator > &seq)
DelimiterPredicate predicate
std::pair< index_t, index_t > row_index_range_t
column_list_impl< 9 > column_list_t
bool join_column(const std::size_t &col, Predicate p, const std::string &delimiter, std::string &result) const
bool operator()(InputIterator begin, InputIterator end)
unsigned long long int type
std::string source_file() const
std::string as_string() const
column_list_impl< N > column_list_t
static bool process(Iterator itr)
static bool process(Iterator itr)
std::size_t split_n(const DelimiterPredicate &p, const std::size_t &n, Sequence< std::string, Allocator > &seq, const split_options::type split_option=split_options::default_mode) const
ext_string operator+(const ext_string &s, const T &t)
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6) const
std::string swap(const std::string &s, const std::size_t &i0, const std::size_t &i1)
unsigned char operator()(const unsigned char c) const
double desired_false_positive_probability_
column_list_impl< 10 > column_list_t
bool write_file(const std::string &file_name, const std::string &buffer)
range_to_type_back_inserter_iterator operator++(int)
std::size_t type_length(const T &)
static void process(Iterator itr, T &t)
range_to_type_push_inserter_iterator< Container > range_to_type_push_inserter(Container &container)
std::string as_lowercase(const std::string &str)
bool operator()(const Sequence< T, Allocator > &sequence) const
ext_string(const range::adapter< char > &r)
bool next_combination(const Iterator first, Iterator k, const Iterator last)
bool operator()(writer &w) const
std::size_t accumulate_column(const std::size_t &col, T &result) const
column_selector_impl(const column_list_t &column_list, T0 &t0)
std::size_t count_consecutive_duplicates(const InputIterator begin, const InputIterator end)
std::size_t remove_empty_tokens(const row_range_t &range)
bool validate_column_range(const col_range_t &range) const
bool operator()(const std::multiset< T, Comparator, Allocator > &multiset) const
back_inserter_with_valuetype_iterator & operator++()
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >, 10 > csb_t
bool begins_with(const InputIterator pattern_begin, const InputIterator pattern_end, const InputIterator begin, const InputIterator end)
trie::prefix< const char *, ValueType > const_char_ptr
bool operator()(const Iterator begin, const Iterator end) const
column_selector_base< column_selector_impl< T0 >, 1 > csb_t
void delete_if(const Predicate &p, std::multiset< T *, Comparator, Allocator > &cont)
bool parse(const col_range_t &range, std::queue< T, Container > &queue) const
inrange_impl< T > & ref()
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7 >, 8 > csb_t
column_selector_base< column_selector_impl< T0, T1, T2, T3, T4, T5, T6 >, 7 > csb_t
InputIterator contains_none(const InputIterator begin, const InputIterator end) const
bool extract_column(const row_range_t &row_range, const std::size_t &index0, const std::size_t &index1, OutputIterator0 out0, OutputIterator1 out1) const
std::string clone() const
adapter(const std::pair< T *, T * > &r)
strtk_register_sequence_type_name(std::vector) strtk_register_sequence_type_name(std
void operator()(const std::pair< Iterator, Iterator > &range) const
void operator()(const std::pair< Iterator, Iterator > &r)
scoped_restore(T &t, const bool restore=true)
range_to_type_inserter_iterator & operator++()
void initialize_n_choose_k()
bool imatch(const std::string &s) const
bool operator()(const std::multiset< T, Allocator, Comparator > &multiset)
bool is_uppercase_letter(const char c)
trie::prefix< const unsigned char *, ValueType > const_uchar_ptr
bool operator()(const InputIterator begin, const InputIterator end)
tokenizer & operator=(const tokenizer &t)
bool concatenate(const std::string &file_name1, const std::string &file_name2, const std::string &output_file_name)
hex_to_string_sink(const hex_to_string_sink &hss)
std::size_t convert_base64_to_bin(const unsigned char *begin, const unsigned char *end, unsigned char *out)
std::deque< iterator_type > token_deque_type
sink_type< std::list< T > > type
unsigned long long int uint64_t
void operator()(const std::pair< Iterator, Iterator > &range)
options & set_row_delimiters(const std::string &delimiters)
std::size_t remove_token_if(const row_range_t &row_range, Predicate predicate)
adapter< const unsigned char > ustring
range_to_type_push_inserter_iterator & operator*()
bool operator()(const std::string &str) const
bool parse_columns(const InputIterator begin, const InputIterator end, const std::string &delimiters, const details::column_list_impl< 12 > &column_list, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11)
std::pair< char_type *, char_type * > range_type
std::size_t ifind_all(const Iterator pattern_begin, const Iterator pattern_end, const Iterator begin, const Iterator end, OutputIterator out)
range_to_type_inserter_iterator & operator*()
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7)
range_to_type_push_inserter_iterator & operator=(const std::pair< Iterator, Iterator > &r)
void convert_to_printable_chars(unsigned char *begin, unsigned char *end)
back_inserter_with_valuetype_iterator< Sequence > back_inserter_with_valuetype(Sequence &sequence_)
multiple_delimiter_predicate(const range::adapter< Type > &r)
std::string left_align(const std::size_t &width, const T &t)
bool operator()(InputIterator begin, InputIterator end) const
void copy_if(Predicate predicate, const InputIterator begin, const InputIterator end, OutputIterator out)
bool contains(const char *data, const std::size_t &length) const
std::string row_delimiters
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
conv_to_ucase_impl(std::string &s)
static std::string transform(const Range &key_range)
bool operator()(const std::pair< Iterator, Iterator > &range) const
details::enable_if< details::supported_iterator_type< T >::value, T >::type type
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9)
options & set_column_delimiters(const std::string &delimiters)
back_inserter_with_valuetype_iterator(const back_inserter_with_valuetype_iterator &it)
static void process(Iterator itr, T &t)
void convert_bin_to_hex(const unsigned char *begin, const unsigned char *end, unsigned char *out)
bool split_pair(const InputIterator begin, const InputIterator end, const Predicate &delimiter, OutputPair &v1, OutputPair &v2)
column_selector_base(const column_list_t &column_list)
void select_1_randomly(const Iterator begin, const Iterator end, OutputIterator out, RandomNumberGenerator &rng)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
strtk_register_attribute_type_tag(unsigned short) strtk_register_attribute_type_tag(unsigned int) strtk_register_attribute_type_tag(unsigned long) strtk_register_attribute_type_tag(unsigned long long int) strtk_register_attribute_type_tag(short) strtk_register_attribute_type_tag(int) strtk_register_attribute_type_tag(long) strtk_register_attribute_type_tag(long long) strtk_register_attribute_type_tag(float) strtk_register_attribute_type_tag(double) strtk_register_attribute_type_tag(long double) strtk_register_attribute_type_tag(unsigned char) strtk_register_attribute_type_tag(signed char) strtk_register_attribute_type_tag(char) strtk_register_attribute_type_tag(std
std::vector< iterator_type > token_vector_type
hex_to_number_sink & operator=(const std::string &s)
void enforce_column_count(const std::size_t &column_count)
range_to_type_push_inserter_iterator(const range_to_type_push_inserter_iterator &it)
bool operator()(const std::string &s) const
bool write_pod_proxy(std::ofstream &stream, const T &t)
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
#define strtk_register_inrange_type_tag(T)
bool load_file(const std::string &file_name, std::string &buffer)
std::size_t distance(const std::pair< Iterator, Iterator > &p)
std::size_t max_column_count() const
void operator()(const typename Set::value_type &v)
strtk::tokenizer< string_iterator_type, multiple_char_delimiter_predicate > md_type
bool operator()(const std::string &str)
iterator_type * iterator_type_ptr
filter operator|(const filter &a, const filter &b)
bool operator()(const std::string &s, const bool ignore_failures=false)
bool parse(const col_range_t &range, std::priority_queue< T, Container, Comparator > &priority_queue) const
std::size_t split(const DelimiterPredicate &delimiter, const Iterator begin, const Iterator end, OutputIterator out, const split_options::type split_option=split_options::default_mode)
Container::value_type value_type
split_options::type row_split_option
bool iends_with(const InputIterator pattern_begin, const InputIterator pattern_end, const InputIterator begin, const InputIterator end)
std::size_t position() const
bool sequential_partition(TransitionPredicate p, Function f)
range_to_ptr_type_iterator(T *pointer, std::size_t &insert_count)
details::like_impl like(const std::string &s)
static bool process(const unsigned char(&c1)[K1], const unsigned char(&c2)[K2])
static bool process(Iterator itr)
semantic_action_type_tag type
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9) const
bool native_to_le(const T &input)
details::fill_array_impl fill_array(unsigned char *data, const std::size_t &size)
const iterator const_iterator
bool operator()(const std::set< T, Comparator, Allocator > &set) const
virtual unsigned long long int size() const
bool operator()(const Range &)
std::size_t for_each_column(const col_range_t &range, Function f) const
void convert_to_uppercase(unsigned char *begin, unsigned char *end)
void make_key_list(const std::map< Key, T, Comparator, MapAllocator > &map, Sequence< Key, SequenceAllocator > &sequence)
column_list_impl< 5 > column_list_t
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, const std::size_t &col4, const std::size_t &col5, const std::size_t &col6, const std::size_t &col7, const std::size_t &col8, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8) const
std::pair< strtk::util::value, bool > value_t
uintkey_map(const Options &options)
strtk::details::column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >::column_list_t column_list_impl< 11 > column_list_t
static ext_string all_chars()
back_inserter_with_valuetype_iterator(Sequence &sequence)
void mark(const std::size_t &v1, char *v2)
strtk_register_pod_type(bool) strtk_register_pod_type(signed char) strtk_register_pod_type(char) strtk_register_pod_type(short) strtk_register_pod_type(int) strtk_register_pod_type(long int) strtk_register_pod_type(long long int) strtk_register_pod_type(unsigned char) strtk_register_pod_type(unsigned short) strtk_register_pod_type(unsigned int) strtk_register_pod_type(unsigned long int) strtk_register_pod_type(unsigned long long int) strtk_register_pod_type(float) strtk_register_pod_type(double) strtk_register_pod_type(long double) template< typename > struct numeric
bool join_row(const std::size_t &row, Predicate predicate, const char *delimiter, std::string &result)
void set_low_hi(const T &low, const T &hi)
bool operator()(T &output)
bool operator()(T &output, const std::size_t &size)
details::short_string_impl< reader::uint16_t > short_string
counting_back_inserter_iterator & operator=(const counting_back_inserter_iterator &itr)
std::size_t ifind(const std::string &pattern, const std::string &data)
bool reset(std::size_t &v1, char *&v2)
const T & previous() const
std::pair< index_t, index_t > row_range_t
DelimiterPredicate predicate_type
column_selector_impl< T, T > type
bool operator()(const Sequence< T, Allocator > &sequence) const
range_to_type_inserter_iterator operator++(int)
bool read_pod_proxy(std::ifstream &stream, T &t)
bool operator==(const char *s, const attribute< std::string > &attrib)
sink_type< std::vector< T > > type
bool signed_numeric_convert(const std::string &s, T &t, const bool digit_check=false)
bool read_at_offset(const std::string &file_name, const std::size_t &offset, std::string &buffer, const std::size_t &buffer_size)
inserter_with_valuetype_iterator & operator*()
void copy_n(InputIterator itr, std::size_t n, OutputIterator out)
bool operator()(const char &c) const
const_iterator & const_iterator_ref
const T & operator()() const
static bool process(Iterator itr)
std::pair< index_t, index_t > col_range_t
std::size_t index() const
std::deque< range_t > token_list_t
bool parse(std::stack< T, Container > &stack) const
bool operator()(strtk::binary::writer &writer)
tokenizer::iterator_type iterator_type
std::size_t current_index_
unsigned long long int n_choose_k(const unsigned long long int &n, const unsigned long long int &k)
bool operator()(const T *data, const uint16_t &length, const bool write_length=true)
bool le_to_native(T &output)
unsigned long long int projected_element_count_
unsigned long long int projected_element_count
token_grid(const std::string &file_name, const std::string &column_delimiters=",|;\t", const std::string &row_delimiters="\n\r")
unsigned char * write_pod(unsigned char *data, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6, const T7 &t7, const T8 &t8, const T9 &t9, const T10 &t10, const T11 &t11, const T12 &t12)
bool parse(T0 &t0, T1 &t1, T2 &t2) const
combination_iterator(const std::string &str)
static bool process(ptr, ptr)
bool parse_with_index(const std::size_t &col0, const std::size_t &col1, const std::size_t &col2, const std::size_t &col3, T0 &t0, T1 &t1, T2 &t2, T3 &t3) const
bool copy_file(const std::string &src_file_name, const std::string &dest_file_name)
filter operator&(const filter &a, const filter &b)
bool parse_nan(Iterator &itr, const Iterator end, T &t)
#define strtk_register_trim_type_tag(T)
void assign(const Iterator begin, const Iterator end)
static bool cmp(ptr c1, ptr c2)
sink_type< Container > & reference()
functional_inserter_iterator & operator=(const functional_inserter_iterator &it)
static bool process(Iterator itr)
std::size_t for_each_token(const std::string &buffer, Tokenizer &tokenizer, Function function)
range_to_type_inserter_iterator(const range_to_type_inserter_iterator &it)
inserter_with_valuetype_iterator & operator=(const inserter_with_valuetype_iterator &itr)
void lexicographically_canonicalize(Iterator begin, Iterator end)
range_to_type_push_inserter_iterator operator++(int)
string_condition(condition_type cond_type, const std::string &str)
static bool process(Iterator itr)
ValueValidator value_validator_type
virtual bool compute_optimal_parameters()
details::conv_to_lcase_impl as_lcase(std::string &s)
bool extract_column(const row_range_t &row_range, const std::size_t &index0, const std::size_t &index1, const std::size_t &index2, const std::size_t &index3, const std::size_t &index4, OutputIterator0 out0, OutputIterator1 out1, OutputIterator2 out2, OutputIterator3 out3, OutputIterator4 out4) const
bool set_array(unsigned char(&a)[N], const std::string &s, const bool pad=false, const unsigned char padding= '0')
void insert(prefix< std::string::iterator, Value > &trie, const char *key, const Value &value=Value(0))
column_list_impl< 9 > column_list_t
static bool process(const char *c1, const char *c2)
sink_type< std::multiset< T > > type
bool operator()(const std::set< T, Comparator, Allocator > &set) const
bool cmpimpl(ptr c1, ptr c2)
container_adder(std::priority_queue< T, Container, Comparator > &pq)
bool parse_inf(Iterator &itr, const Iterator end, T &t, bool negative)
combination_iterator(Sequence< T, Allocator > &seq)
bool find(prefix< std::string::const_iterator, Value > &trie, const char *key, Value &v)
#define strtk_register_hex_number_type_tag(T)
void remove_row(const std::size_t &index)
bound_range(Function f, Iterator first, Iterator last)
bool operator()(std::multiset< T, Allocator, Comparator > &multiset)
std::size_t target_index_
std::size_t convert_bin_to_base64(const unsigned char *begin, const unsigned char *end, unsigned char *out)
bool operator==(const semantic_action_impl &sa) const
std::size_t split(const DelimiterPredicate &p, Sequence< std::string, Allocator > &seq, const split_options::type split_option=split_options::default_mode) const
container_adder(std::queue< T, Container > &queue)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
bool operator()(const std::multiset< T, Comparator, Allocator > &multiset) const
bool register_keyvalue(const typename KeyValueMap::key_type &key, T &t)
inserter_with_valuetype_iterator operator++(int)
bool operator()(const T &input)
bool add(std::pair< InputIterator, InputIterator > &range) const
range_type< Iterator >::type find_atleast_n_consecutive_values(const std::size_t n, Predicate p, Iterator itr, const Iterator end)
token_grid(const char *input_buffer, const std::size_t &input_buffer_size, const std::string &column_delimiters=",|;\t", const std::string &row_delimiters="\n\r")
ext_string & to_lowercase()
const std::string & as_string() const
std::size_t for_each_line_conditional(std::istream &stream, Function function, const std::size_t &buffer_size=one_kilobyte)
const char * position_ptr() const
ext_string & to_uppercase()
const char * position_ptr() const
std::string as_string(const adapter< const char > &a)
ext_string(const std::string &s)
std::pair< InputIterator, InputIterator > iterator_type
bool extract_column(const row_range_t &row_range, const std::size_t &index0, const std::size_t &index1, const std::size_t &index2, OutputIterator0 out0, OutputIterator1 out1, OutputIterator2 out2) const
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
bool convert_hex_to_bin(const unsigned char *begin, const unsigned char *end, unsigned char *out)
bool operator()(const std::string &str) const
range_to_type_back_inserter_iterator< Sequence > range_to_type_back_inserter(Sequence &sequence)
std::size_t split_n(const DelimiterPredicate &p, const std::size_t &n, OutputIterator out, const split_options::type split_option=split_options::default_mode) const
bool operator()(const std::pair< Iterator, Iterator > &range) const
conv_to_lcase_impl(std::string &s)
void set_bit_high(const std::size_t &index, unsigned char *const ptr)
iexpect_impl(const std::string &s)
bool type_to_string(const T &t, std::string &s)
unsigned long long int uint64_t
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3) const
bool operator()(const std::multiset< T, Comparator, Allocator > &multiset) const
tokenizer(const std::string &s, const DelimiterPredicate &predicate, const tokenize_options::type tokenize_options=tokenize_options::default_mode)
const cell_type * table() const
void parse_checked(std::multiset< T, Comparator, Allocator > &multiset) const
T min_of_cont(const Sequence< T, Allocator > &sequence)
fill_array_impl & set(char *data, const std::size_t &size)
std::size_t high_bit_count(const unsigned char c)
sequence_t::const_iterator end_
bool operator!=(const TConvertibleType &t)
std::size_t operator()(std::ofstream &stream)
Iterator inc(Iterator itr, const std::size_t &n)
bool parse(const col_range_t &range, Sequence< T, Allocator > &sequence) const
std::size_t remove_leading(Predicate predicate, Iterator begin, Iterator end)
writer(T *buffer, const std::size_t &buffer_length)
index_remover_impl(const sequence_t &sequence)
void translate_inplace(const translation_table &trans_table, std::string &s)
void set_value(const std::string &s)
const iterator const_iterator
combination_iterator operator++(int)
static void process(Iterator itr, T &t)
bound_range_conditional(Function f, Iterator first, Iterator last)
bool operator()(InputIterator begin, InputIterator end)
column_selector_base< column_selector_impl< T0, T1 >, 2 > csb_t
void operator()(const T &)
std::size_t split(const DelimiterPredicate &p, OutputIterator out, const split_options::type split_option=split_options::default_mode) const
static bool process(details::ptr c1, details::ptr c2)
column_selector_impl(const column_list_t &column_list, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11)
bool string_to_type_converter_impl_ref(Iterator &itr, const Iterator end, T &result, signed_type_tag)
strtk_register_unsigned_type_tag(unsigned short) strtk_register_unsigned_type_tag(unsigned int) strtk_register_unsigned_type_tag(unsigned long) strtk_register_unsigned_type_tag(unsigned long long int) strtk_register_signed_type_tag(short) strtk_register_signed_type_tag(int) strtk_register_signed_type_tag(long) strtk_register_signed_type_tag(long long) strtk_register_real_type_tag(float) strtk_register_real_type_tag(double) strtk_register_real_type_tag(long double) strtk_register_byte_type_tag(unsigned char) strtk_register_byte_type_tag(signed char) strtk_register_byte_type_tag(char) strtk_register_hex_number_type_tag(hex_to_number_sink< short >) strtk_register_hex_number_type_tag(hex_to_number_sink< int >) strtk_register_hex_number_type_tag(hex_to_number_sink< long >) strtk_register_hex_number_type_tag(hex_to_number_sink< unsigned short >) strtk_register_hex_number_type_tag(hex_to_number_sink< unsigned int >) strtk_register_hex_number_type_tag(hex_to_number_sink< unsigned long >) strtk_register_hex_number_type_tag(hex_to_number_sink< unsigned long long int >) strtk_register_base64_type_tag(base64_to_number_sink< short >) strtk_register_base64_type_tag(base64_to_number_sink< int >) strtk_register_base64_type_tag(base64_to_number_sink< long >) strtk_register_base64_type_tag(base64_to_number_sink< unsigned short >) strtk_register_base64_type_tag(base64_to_number_sink< unsigned int >) strtk_register_base64_type_tag(base64_to_number_sink< unsigned long >) strtk_register_base64_type_tag(base64_to_number_sink< unsigned long long int >) strtk_register_stdstring_range_type_tag(std
bool find_prefix(const key_iterator_t begin, const key_iterator_t end) const
std::list< iterator_type > token_list_type
static void process(Iterator itr, T &t)
static ext_string all_letters()
bool convert_string_range(const std::pair< std::string::const_iterator, std::string::const_iterator > &range, T &t)
bool operator()(const std::multiset< T, Comparator, Allocator > &multiset) const
row_range_t range(std::size_t lower_bound, std::size_t upper_bound=std::numeric_limits< std::size_t >::max()) const
tuple f
First do the data loading part.
column_selector_iterator_impl(const details::column_list_impl< N > &column_list, iterator_type(&token_list)[N])
void replace_pattern(const std::string &s, const std::string &p, const std::string &r, std::string &n)
sink_type< std::set< T > > type
#define strtk_parse_col_token(Index)
std::size_t split_regex_n(const boost::regex &delimiter_expression, const InputIterator begin, const InputIterator end, const std::size_t &token_count, OutputIterator out, const regex_match_mode::type mode=regex_match_mode::match_all)
parser(const Options &opts)
split_options::type column_split_option
bool operator()(const std::pair< Iterator, Iterator > &range) const
bool parse(T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5) const
column_selector_impl(const column_list_t &column_list, T1 &t0, T1 &t1)
column_list_impl< 7 > column_list_t
#define strtk_register_real_type_tag(T)
bool operator()(const T &output)
bool read_from_file(const std::string &file_name)
static void process(Iterator itr, T &t)
not_supported_type_tag type
#define strtk_register_pair_to_ostream(Iterator)
std::pair< Iterator1, Iterator2 > make_pair(const std::string &s)
col_range_t range(const std::size_t &lower_bound, const std::size_t &upper_bound=std::numeric_limits< std::size_t >::max()) const
options & set_column_split_option(const split_options::type &option)
unsigned char * read_pod(unsigned char *data, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10, T11 &t11, T12 &t12)
bool join_row(const std::size_t &row, const std::string &delimiter, std::string &result)
functional_inserter_iterator & operator++()
std::string make_string(const unsigned char(&s)[N], const std::size_t &length=N)
bool operator()(const Range &key_range, const Range &value_range)
void remaining_string(const std::size_t &index, const std::string &str, std::string &result)
bool random_combination(const Iterator begin, const Iterator end, std::size_t set_size, RandomNumberGenerator &rng, OutputIterator out)
void extract_column_checked(const std::size_t &index, std::set< T, Comparator, Allocator > &set) const
fillchararray_type_tag type
bool seek(const int &n_bytes)
range_t token(const std::size_t &index) const
fill_array_impl & set_size(const std::size_t &size)
std::string right_align(const std::size_t &width, const T &t)
details::trim_impl< T > trim_trailing(const std::string &rem_chars, T &t)
strtk::details::column_selector_impl< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >::column_selector_impl column_selector_impl(const column_list_t &column_list, T0 &t0, T1 &t1, T2 &t2, T3 &t3, T4 &t4, T5 &t5, T6 &t6, T7 &t7, T8 &t8, T9 &t9, T10 &t10)
std::size_t remove_empty_tokens()
push_inserter_iterator< Container > & operator*()
bool remove_row_if(Predicate predicate)
std::size_t accumulate_column(const std::size_t &col, const row_range_t &row_range, Predicate p, T &result) const
filter operator^(const filter &a, const filter &b)
column_list_impl< 7 > column_list_t
std::size_t raw_length() const
bool operator()(const Sequence< T, Allocator > &sequence) const
bool operator()(const std::string &str) const
bool file_exists(const std::string &file_name)
hex_to_string_sink & operator=(const hex_to_string_sink &hss)
static void process(Iterator itr, T &t)
static ext_string all_uppercase_letters()
expect_impl(const std::string &s)
trie::prefix< unsigned char *, ValueType > uchar_ptr
void enforce_min_max_column_count(const row_range_t &row_range, const std::size_t &min_column_count, const std::size_t &max_column_count)
bool operator()(const T *data, const uint64_t &length, const bool write_length=true)
T max_of_cont(const Sequence< T, Allocator > &sequence)
options(split_options::type sro, split_options::type sco, const std::string &rd, const std::string &cd, const bool support_dq=false)
bool operator()(const std::set< T, Comparator, Allocator > &set) const
void process(const std::pair< Iterator, Iterator > &r)
bool imatch(const InputIterator begin1, const InputIterator end1, const InputIterator begin2, const InputIterator end2)
static type create(const column_list_t &col_list, std::list< T, Allocator > &list)
static type create(const column_list_t &col_list, Sequence< T, Allocator > &seq)
static bool process(Iterator)
bool ibegins_with(const InputIterator pattern_begin, const InputIterator pattern_end, const InputIterator begin, const InputIterator end)
void parse_checked(OutputIterator out) const
std::string as_string() const
bool operator()(const std::pair< T1, T2 > &p)
void fill(std::string &s, const std::string::value_type v)
unsigned long long int maximum_size
single_delimiter_predicate(const T &d)
bool read_line_as_value(std::istream &stream, T &t, const std::size_t &buffer_size=one_kilobyte)
void extract_unique(const InputIterator begin, const InputIterator end, OutputIterator out)
bool operator!=(const combination_iterator &itr) const
column_selector_impl< T, T, T, T, T, T, T, T > type
bool combine_discontinuous_conditional(Iterator first1, Iterator last1, typename std::iterator_traits< Iterator >::difference_type d1, Iterator first2, Iterator last2, typename std::iterator_traits< Iterator >::difference_type d2, Function &f, typename std::iterator_traits< Iterator >::difference_type d=0)
T operator[](const std::size_t &index) const
back_inserter_with_valuetype_iterator & operator=(const back_inserter_with_valuetype_iterator &it)
details::short_string_impl< reader::uint8_t > pascal_string